PluginProbe
Elementor Website Builder – more than just a page builder / 3.29.2
Elementor Website Builder – more than just a page builder v3.29.2
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / modules / atomic-widgets / elements / atomic-image / atomic-image.php

atomic-image.php in Elementor Website Builder – more than just a page builder 3.29.2, at modules/atomic-widgets/elements/atomic-image/atomic-image.php

90 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Modules\AtomicWidgets\Elements\Atomic_Image;
3
4 use Elementor\Modules\AtomicWidgets\Controls\Types\Link_Control;
5 use Elementor\Modules\AtomicWidgets\Elements\Has_Template;
6 use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type;
7 use Elementor\Modules\AtomicWidgets\PropTypes\Image_Prop_Type;
8 use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type;
9 use Elementor\Modules\AtomicWidgets\Controls\Section;
10 use Elementor\Modules\AtomicWidgets\Elements\Atomic_Widget_Base;
11 use Elementor\Modules\AtomicWidgets\Controls\Types\Image_Control;
12 use Elementor\Modules\AtomicWidgets\Image\Placeholder_Image;
13 use Elementor\Modules\AtomicWidgets\Styles\Style_Definition;
14 use Elementor\Modules\AtomicWidgets\Styles\Style_Variant;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit; // Exit if accessed directly.
18 }
19
20 class Atomic_Image extends Atomic_Widget_Base {
21 use Has_Template;
22
23 const LINK_BASE_STYLE_KEY = 'link-base';
24 const BASE_STYLE_KEY = 'base';
25
26 public static function get_element_type(): string {
27 return 'e-image';
28 }
29
30 public function get_title() {
31 return esc_html__( 'Image', 'elementor' );
32 }
33
34 public function get_keywords() {
35 return [ 'ato', 'atom', 'atoms', 'atomic' ];
36 }
37
38 public function get_icon() {
39 return 'eicon-e-image';
40 }
41
42 protected static function define_props_schema(): array {
43 return [
44 'classes' => Classes_Prop_Type::make()
45 ->default( [] ),
46
47 'image' => Image_Prop_Type::make()
48 ->default_url( Placeholder_Image::get_placeholder_image() )
49 ->default_size( 'full' ),
50
51 'link' => Link_Prop_Type::make(),
52 ];
53 }
54
55 protected function define_atomic_controls(): array {
56 $content_section = Section::make()
57 ->set_label( esc_html__( 'Content', 'elementor' ) )
58 ->set_items( [
59 Image_Control::bind_to( 'image' ),
60 Link_Control::bind_to( 'link' ),
61 ] );
62
63 return [
64 $content_section,
65 ];
66 }
67
68 protected function define_base_styles(): array {
69 return [
70 self::LINK_BASE_STYLE_KEY => Style_Definition::make()
71 ->add_variant(
72 Style_Variant::make()
73 ->add_prop( 'display', 'inherit' )
74 ->add_prop( 'width', 'fit-content' )
75 ),
76 self::BASE_STYLE_KEY => Style_Definition::make()
77 ->add_variant(
78 Style_Variant::make()
79 ->add_prop( 'display', 'block' )
80 ),
81 ];
82 }
83
84 protected function get_templates(): array {
85 return [
86 'elementor/elements/atomic-image' => __DIR__ . '/atomic-image.html.twig',
87 ];
88 }
89 }
90