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

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