← All changes
|
modules/atomic-widgets/elements/atomic-image/atomic-image.php
+14
-37
4.3.0-beta3
→
3.32.0-dev3
View file →
| @@ -1,22 +1,20 @@ | ||
| 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\Elements\Base\Html_Tag_Computer; | |
| 10 | +use Elementor\Modules\AtomicWidgets\Elements\Atomic_Widget_Base; | |
| 12 | 11 | use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type; |
| 13 | 12 | use Elementor\Modules\AtomicWidgets\Controls\Types\Image_Control; |
| 14 | -use Elementor\Modules\AtomicWidgets\Utils\Image\Placeholder_Image; | |
| 13 | +use Elementor\Modules\AtomicWidgets\Image\Placeholder_Image; | |
| 15 | 14 | use Elementor\Modules\AtomicWidgets\Styles\Style_Definition; |
| 16 | 15 | use Elementor\Modules\AtomicWidgets\Styles\Style_Variant; |
| 17 | 16 | use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control; |
| 18 | -use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type; | |
| 19 | 17 | |
| 20 | 18 | if ( ! defined( 'ABSPATH' ) ) { |
| 21 | 19 | exit; // Exit if accessed directly. |
| 22 | 20 | } |
| @@ -23,10 +21,8 @@ | ||
| 23 | 21 | |
| 24 | 22 | class Atomic_Image extends Atomic_Widget_Base { |
| 25 | 23 | use Has_Template; |
| 26 | 24 | |
| 27 | - public static $widget_description = 'Display an image with customizable styles and link options.'; | |
| 28 | - | |
| 29 | 25 | const LINK_BASE_STYLE_KEY = 'link-base'; |
| 30 | 26 | const BASE_STYLE_KEY = 'base'; |
| 31 | 27 | |
| 32 | 28 | public static function get_element_type(): string { |
| @@ -37,9 +33,9 @@ | ||
| 37 | 33 | return esc_html__( 'Image', 'elementor' ); |
| 38 | 34 | } |
| 39 | 35 | |
| 40 | 36 | public function get_keywords() { |
| 41 | - return [ 'ato', 'atom', 'atoms', 'atomic', 'image', 'photo', 'picture' ]; | |
| 37 | + return [ 'ato', 'atom', 'atoms', 'atomic' ]; | |
| 42 | 38 | } |
| 43 | 39 | |
| 44 | 40 | public function get_icon() { |
| 45 | 41 | return 'eicon-e-image'; |
| @@ -44,18 +40,8 @@ | ||
| 44 | 40 | public function get_icon() { |
| 45 | 41 | return 'eicon-e-image'; |
| 46 | 42 | } |
| 47 | 43 | |
| 48 | - public static function html_tag_follows_link(): bool { | |
| 49 | - return false; | |
| 50 | - } | |
| 51 | - | |
| 52 | - public static function get_computed_html_tag( array $settings ): string { | |
| 53 | - return Html_Tag_Computer::compute( $settings, 'img', [ | |
| 54 | - Html_Tag_Computer::FOLLOW_LINK_OPTION => static::html_tag_follows_link(), | |
| 55 | - ] ); | |
| 56 | - } | |
| 57 | - | |
| 58 | 44 | protected static function define_props_schema(): array { |
| 59 | 45 | $props = [ |
| 60 | 46 | 'classes' => Classes_Prop_Type::make() |
| 61 | 47 | ->default( [] ), |
| @@ -65,9 +51,9 @@ | ||
| 65 | 51 | ->default_size( 'full' ), |
| 66 | 52 | |
| 67 | 53 | 'link' => Link_Prop_Type::make(), |
| 68 | 54 | |
| 69 | - 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ), | |
| 55 | + 'attributes' => Attributes_Prop_Type::make(), | |
| 70 | 56 | ]; |
| 71 | 57 | |
| 72 | 58 | return $props; |
| 73 | 59 | } |
| @@ -75,11 +61,11 @@ | ||
| 75 | 61 | protected function define_atomic_controls(): array { |
| 76 | 62 | return [ |
| 77 | 63 | Section::make() |
| 78 | 64 | ->set_label( esc_html__( 'Content', 'elementor' ) ) |
| 79 | - ->set_id( 'content' ) | |
| 80 | 65 | ->set_items( [ |
| 81 | 66 | Image_Control::bind_to( 'image' ) |
| 67 | + ->set_show_mode( 'media' ) | |
| 82 | 68 | ->set_label( __( 'Image', 'elementor' ) ), |
| 83 | 69 | ] ), |
| 84 | 70 | Section::make() |
| 85 | 71 | ->set_label( __( 'Settings', 'elementor' ) ) |
| @@ -89,11 +75,17 @@ | ||
| 89 | 75 | } |
| 90 | 76 | |
| 91 | 77 | protected function get_settings_controls(): array { |
| 92 | 78 | return [ |
| 79 | + Image_Control::bind_to( 'image' ) | |
| 80 | + ->set_show_mode( 'sizes' ) | |
| 81 | + ->set_label( __( 'Image resolution', 'elementor' ) ) | |
| 82 | + ->set_meta( [ 'layout' => 'two-columns' ] ), | |
| 93 | 83 | Link_Control::bind_to( 'link' ) |
| 94 | - ->set_placeholder( __( 'Type or paste your URL', 'elementor' ) ) | |
| 95 | - ->set_label( __( 'Link', 'elementor' ) ), | |
| 84 | + ->set_label( __( 'Link', 'elementor' ) ) | |
| 85 | + ->set_meta( [ | |
| 86 | + 'topDivider' => true, | |
| 87 | + ] ), | |
| 96 | 88 | Text_Control::bind_to( '_cssid' ) |
| 97 | 89 | ->set_label( __( 'ID', 'elementor' ) ) |
| 98 | 90 | ->set_meta( $this->get_css_id_control_meta() ), |
| 99 | 91 | ]; |
| @@ -103,12 +95,10 @@ | ||
| 103 | 95 | return [ |
| 104 | 96 | self::LINK_BASE_STYLE_KEY => Style_Definition::make() |
| 105 | 97 | ->add_variant( |
| 106 | 98 | Style_Variant::make() |
| 107 | - ->add_prop( 'all', 'unset' ) | |
| 108 | 99 | ->add_prop( 'display', 'inherit' ) |
| 109 | 100 | ->add_prop( 'width', 'fit-content' ) |
| 110 | - ->add_prop( 'cursor', 'pointer' ) | |
| 111 | 101 | ), |
| 112 | 102 | self::BASE_STYLE_KEY => Style_Definition::make() |
| 113 | 103 | ->add_variant( |
| 114 | 104 | Style_Variant::make() |
| @@ -120,19 +110,6 @@ | ||
| 120 | 110 | protected function get_templates(): array { |
| 121 | 111 | return [ |
| 122 | 112 | 'elementor/elements/atomic-image' => __DIR__ . '/atomic-image.html.twig', |
| 123 | 113 | ]; |
| 124 | - } | |
| 125 | - | |
| 126 | - public function render_markdown(): string { | |
| 127 | - $settings = $this->get_atomic_settings(); | |
| 128 | - $src = $settings['image']['src'] ?? ''; | |
| 129 | - | |
| 130 | - if ( empty( $src ) ) { | |
| 131 | - return ''; | |
| 132 | - } | |
| 133 | - | |
| 134 | - $alt = $settings['image']['alt'] ?? ''; | |
| 135 | - | |
| 136 | - return ' . ')'; | |
| 137 | 114 | } |
| 138 | 115 | } |