PluginProbe
Elementor Website Builder – more than just a page builder / 3.30.0-dev3
Elementor Website Builder – more than just a page builder v3.30.0-dev3
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.30.0-dev3, at modules/atomic-widgets/elements/atomic-image/atomic-image.php

118 lines 3.3 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\Controls\Types\Text_Control;
6 use Elementor\Modules\AtomicWidgets\Elements\Has_Template;
7 use Elementor\Modules\AtomicWidgets\Module;
8 use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type;
9 use Elementor\Modules\AtomicWidgets\PropTypes\Image_Prop_Type;
10 use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type;
11 use Elementor\Modules\AtomicWidgets\Controls\Section;
12 use Elementor\Modules\AtomicWidgets\Elements\Atomic_Widget_Base;
13 use Elementor\Modules\AtomicWidgets\Controls\Types\Image_Control;
14 use Elementor\Modules\AtomicWidgets\Image\Placeholder_Image;
15 use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type;
16 use Elementor\Modules\AtomicWidgets\Styles\Style_Definition;
17 use Elementor\Modules\AtomicWidgets\Styles\Style_Variant;
18 use Elementor\Plugin;
19
20 if ( ! defined( 'ABSPATH' ) ) {
21 exit; // Exit if accessed directly.
22 }
23
24 class Atomic_Image extends Atomic_Widget_Base {
25 use Has_Template;
26
27 const LINK_BASE_STYLE_KEY = 'link-base';
28 const BASE_STYLE_KEY = 'base';
29
30 public static function get_element_type(): string {
31 return 'e-image';
32 }
33
34 public function get_title() {
35 return esc_html__( 'Image', 'elementor' );
36 }
37
38 public function get_keywords() {
39 return [ 'ato', 'atom', 'atoms', 'atomic' ];
40 }
41
42 public function get_icon() {
43 return 'eicon-e-image';
44 }
45
46 protected static function define_props_schema(): array {
47 $props = [
48 'classes' => Classes_Prop_Type::make()
49 ->default( [] ),
50
51 'image' => Image_Prop_Type::make()
52 ->default_url( Placeholder_Image::get_placeholder_image() )
53 ->default_size( 'full' ),
54
55 'link' => Link_Prop_Type::make(),
56 ];
57
58 if ( Plugin::$instance->experiments->is_feature_active( Module::EXPERIMENT_VERSION_3_30 ) ) {
59 $props['_cssid'] = String_Prop_Type::make();
60 }
61
62 return $props;
63 }
64
65 protected function define_atomic_controls(): array {
66 $content_section = Section::make()
67 ->set_label( esc_html__( 'Content', 'elementor' ) )
68 ->set_items( [
69 Image_Control::bind_to( 'image' )
70 ->set_show_mode( 'media' ),
71 ] );
72
73 $settings_section_items = [
74 Image_Control::bind_to( 'image' )
75 ->set_show_mode( 'sizes' ),
76 Link_Control::bind_to( 'link' )->set_meta( [
77 'topDivider' => true,
78 ] ),
79 ];
80
81 if ( Plugin::$instance->experiments->is_feature_active( Module::EXPERIMENT_VERSION_3_30 ) ) {
82 $settings_section_items[] = Text_Control::bind_to( '_cssid' )->set_label( __( 'ID', 'elementor' ) )->set_meta( [
83 'layout' => 'two-columns',
84 'topDivider' => true,
85 ] );
86 }
87
88 return [
89 $content_section,
90 Section::make()
91 ->set_label( esc_html__( 'Settings', 'elementor' ) )
92 ->set_items( $settings_section_items ),
93 ];
94 }
95
96 protected function define_base_styles(): array {
97 return [
98 self::LINK_BASE_STYLE_KEY => Style_Definition::make()
99 ->add_variant(
100 Style_Variant::make()
101 ->add_prop( 'display', 'inherit' )
102 ->add_prop( 'width', 'fit-content' )
103 ),
104 self::BASE_STYLE_KEY => Style_Definition::make()
105 ->add_variant(
106 Style_Variant::make()
107 ->add_prop( 'display', 'block' )
108 ),
109 ];
110 }
111
112 protected function get_templates(): array {
113 return [
114 'elementor/elements/atomic-image' => __DIR__ . '/atomic-image.html.twig',
115 ];
116 }
117 }
118