← All changes
|
modules/atomic-widgets/elements/atomic-image/atomic-image.php
+15
-35
4.2.4
→
3.31.4
View file →
| @@ -1,21 +1,19 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor\Modules\AtomicWidgets\Elements\Atomic_Image; |
| 3 | 3 | |
| 4 | 4 | use Elementor\Modules\AtomicWidgets\Controls\Types\Link_Control; |
| 5 | -use Elementor\Modules\AtomicWidgets\Elements\Base\Has_Template; | |
| 5 | +use Elementor\Modules\AtomicWidgets\Elements\Has_Template; | |
| 6 | 6 | use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type; |
| 7 | 7 | use Elementor\Modules\AtomicWidgets\PropTypes\Image_Prop_Type; |
| 8 | 8 | use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type; |
| 9 | 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; | |
| 10 | +use Elementor\Modules\AtomicWidgets\Elements\Atomic_Widget_Base; | |
| 11 | +use Elementor\Modules\AtomicWidgets\PropTypes\Key_Value_Array_Prop_Type; | |
| 12 | 12 | use Elementor\Modules\AtomicWidgets\Controls\Types\Image_Control; |
| 13 | -use Elementor\Modules\AtomicWidgets\Utils\Image\Placeholder_Image; | |
| 13 | +use Elementor\Modules\AtomicWidgets\Image\Placeholder_Image; | |
| 14 | 14 | use Elementor\Modules\AtomicWidgets\Styles\Style_Definition; |
| 15 | 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 | 16 | |
| 19 | 17 | if ( ! defined( 'ABSPATH' ) ) { |
| 20 | 18 | exit; // Exit if accessed directly. |
| 21 | 19 | } |
| @@ -22,10 +20,8 @@ | ||
| 22 | 20 | |
| 23 | 21 | class Atomic_Image extends Atomic_Widget_Base { |
| 24 | 22 | use Has_Template; |
| 25 | 23 | |
| 26 | - public static $widget_description = 'Display an image with customizable styles and link options.'; | |
| 27 | - | |
| 28 | 24 | const LINK_BASE_STYLE_KEY = 'link-base'; |
| 29 | 25 | const BASE_STYLE_KEY = 'base'; |
| 30 | 26 | |
| 31 | 27 | public static function get_element_type(): string { |
| @@ -54,9 +50,9 @@ | ||
| 54 | 50 | ->default_size( 'full' ), |
| 55 | 51 | |
| 56 | 52 | 'link' => Link_Prop_Type::make(), |
| 57 | 53 | |
| 58 | - 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ), | |
| 54 | + 'attributes' => Key_Value_Array_Prop_Type::make(), | |
| 59 | 55 | ]; |
| 60 | 56 | |
| 61 | 57 | return $props; |
| 62 | 58 | } |
| @@ -64,28 +60,27 @@ | ||
| 64 | 60 | protected function define_atomic_controls(): array { |
| 65 | 61 | return [ |
| 66 | 62 | Section::make() |
| 67 | 63 | ->set_label( esc_html__( 'Content', 'elementor' ) ) |
| 68 | - ->set_id( 'content' ) | |
| 69 | 64 | ->set_items( [ |
| 70 | 65 | Image_Control::bind_to( 'image' ) |
| 71 | - ->set_label( __( 'Image', 'elementor' ) ), | |
| 66 | + ->set_label( __( 'Image', 'elementor' ) ) | |
| 67 | + ->set_show_mode( 'media' ), | |
| 72 | 68 | ] ), |
| 73 | - Section::make() | |
| 74 | - ->set_label( __( 'Settings', 'elementor' ) ) | |
| 75 | - ->set_id( 'settings' ) | |
| 76 | - ->set_items( $this->get_settings_controls() ), | |
| 77 | 69 | ]; |
| 78 | 70 | } |
| 79 | 71 | |
| 80 | 72 | protected function get_settings_controls(): array { |
| 81 | 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' ] ), | |
| 82 | 78 | Link_Control::bind_to( 'link' ) |
| 83 | - ->set_placeholder( __( 'Type or paste your URL', 'elementor' ) ) | |
| 84 | - ->set_label( __( 'Link', 'elementor' ) ), | |
| 85 | - Text_Control::bind_to( '_cssid' ) | |
| 86 | - ->set_label( __( 'ID', 'elementor' ) ) | |
| 87 | - ->set_meta( $this->get_css_id_control_meta() ), | |
| 79 | + ->set_label( __( 'Link', 'elementor' ) ) | |
| 80 | + ->set_meta( [ | |
| 81 | + 'topDivider' => true, | |
| 82 | + ] ), | |
| 88 | 83 | ]; |
| 89 | 84 | } |
| 90 | 85 | |
| 91 | 86 | protected function define_base_styles(): array { |
| @@ -92,12 +87,10 @@ | ||
| 92 | 87 | return [ |
| 93 | 88 | self::LINK_BASE_STYLE_KEY => Style_Definition::make() |
| 94 | 89 | ->add_variant( |
| 95 | 90 | Style_Variant::make() |
| 96 | - ->add_prop( 'all', 'unset' ) | |
| 97 | 91 | ->add_prop( 'display', 'inherit' ) |
| 98 | 92 | ->add_prop( 'width', 'fit-content' ) |
| 99 | - ->add_prop( 'cursor', 'pointer' ) | |
| 100 | 93 | ), |
| 101 | 94 | self::BASE_STYLE_KEY => Style_Definition::make() |
| 102 | 95 | ->add_variant( |
| 103 | 96 | Style_Variant::make() |
| @@ -109,19 +102,6 @@ | ||
| 109 | 102 | protected function get_templates(): array { |
| 110 | 103 | return [ |
| 111 | 104 | 'elementor/elements/atomic-image' => __DIR__ . '/atomic-image.html.twig', |
| 112 | 105 | ]; |
| 113 | - } | |
| 114 | - | |
| 115 | - public function render_markdown(): string { | |
| 116 | - $settings = $this->get_atomic_settings(); | |
| 117 | - $src = $settings['image']['src'] ?? ''; | |
| 118 | - | |
| 119 | - if ( empty( $src ) ) { | |
| 120 | - return ''; | |
| 121 | - } | |
| 122 | - | |
| 123 | - $alt = $settings['image']['alt'] ?? ''; | |
| 124 | - | |
| 125 | - return ' . ')'; | |
| 126 | 106 | } |
| 127 | 107 | } |