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

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