PluginProbe
Elementor Website Builder – more than just a page builder / 3.14.0-beta4
Elementor Website Builder – more than just a page builder v3.14.0-beta4
4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.3.0-beta3 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 All 457 releases
← All changes | includes/widgets/image.php +65 -147 4.1.1 → 3.14.0-beta4 View file →
@@ -88,31 +88,9 @@
88 88 public function get_keywords() {
89 89 return [ 'image', 'photo', 'visual' ];
90 90 }
91 91
92 - protected function is_dynamic_content(): bool {
93 - return false;
94 - }
95 -
96 92 /**
97 - * Get style dependencies.
98 - *
99 - * Retrieve the list of style dependencies the widget requires.
100 - *
101 - * @since 3.24.0
102 - * @access public
103 - *
104 - * @return array Widget style dependencies.
105 - */
106 - public function get_style_depends(): array {
107 - return [ 'widget-image' ];
108 - }
109 -
110 - public function has_widget_inner_wrapper(): bool {
111 - return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
112 - }
113 -
114 - /**
115 93 * Register image widget controls.
116 94 *
117 95 * Adds different input fields to allow the user to change and customize the widget settings.
118 96 *
@@ -145,11 +123,34 @@
145 123 Group_Control_Image_Size::get_type(),
146 124 [
147 125 'name' => 'image', // Usage: `{name}_size` and `{name}_custom_dimension`, in this case `image_size` and `image_custom_dimension`.
148 126 'default' => 'large',
149 - 'condition' => [
150 - 'image[url]!' => '',
127 + 'separator' => 'none',
128 + ]
129 + );
130 +
131 + $this->add_responsive_control(
132 + 'align',
133 + [
134 + 'label' => esc_html__( 'Alignment', 'elementor' ),
135 + 'type' => Controls_Manager::CHOOSE,
136 + 'options' => [
137 + 'left' => [
138 + 'title' => esc_html__( 'Left', 'elementor' ),
139 + 'icon' => 'eicon-text-align-left',
140 + ],
141 + 'center' => [
142 + 'title' => esc_html__( 'Center', 'elementor' ),
143 + 'icon' => 'eicon-text-align-center',
144 + ],
145 + 'right' => [
146 + 'title' => esc_html__( 'Right', 'elementor' ),
147 + 'icon' => 'eicon-text-align-right',
148 + ],
151 149 ],
150 + 'selectors' => [
151 + '{{WRAPPER}}' => 'text-align: {{VALUE}};',
152 + ],
152 153 ]
153 154 );
154 155
155 156 $this->add_control(
@@ -162,11 +163,8 @@
162 163 'attachment' => esc_html__( 'Attachment Caption', 'elementor' ),
163 164 'custom' => esc_html__( 'Custom Caption', 'elementor' ),
164 165 ],
165 166 'default' => 'none',
166 - 'condition' => [
167 - 'image[url]!' => '',
168 - ],
169 167 ]
170 168 );
171 169
172 170 $this->add_control(
@@ -176,9 +174,8 @@
176 174 'type' => Controls_Manager::TEXT,
177 175 'default' => '',
178 176 'placeholder' => esc_html__( 'Enter your image caption', 'elementor' ),
179 177 'condition' => [
180 - 'image[url]!' => '',
181 178 'caption_source' => 'custom',
182 179 ],
183 180 'dynamic' => [
184 181 'active' => true,
@@ -196,11 +193,8 @@
196 193 'none' => esc_html__( 'None', 'elementor' ),
197 194 'file' => esc_html__( 'Media File', 'elementor' ),
198 195 'custom' => esc_html__( 'Custom URL', 'elementor' ),
199 196 ],
200 - 'condition' => [
201 - 'image[url]!' => '',
202 - ],
203 197 ]
204 198 );
205 199
206 200 $this->add_control(
@@ -210,10 +204,10 @@
210 204 'type' => Controls_Manager::URL,
211 205 'dynamic' => [
212 206 'active' => true,
213 207 ],
208 + 'placeholder' => esc_html__( 'https://your-link.com', 'elementor' ),
214 209 'condition' => [
215 - 'image[url]!' => '',
216 210 'link_to' => 'custom',
217 211 ],
218 212 'show_label' => false,
219 213 ]
@@ -236,14 +230,22 @@
236 230 'yes' => esc_html__( 'Yes', 'elementor' ),
237 231 'no' => esc_html__( 'No', 'elementor' ),
238 232 ],
239 233 'condition' => [
240 - 'image[url]!' => '',
241 234 'link_to' => 'file',
242 235 ],
243 236 ]
244 237 );
245 238
239 + $this->add_control(
240 + 'view',
241 + [
242 + 'label' => esc_html__( 'View', 'elementor' ),
243 + 'type' => Controls_Manager::HIDDEN,
244 + 'default' => 'traditional',
245 + ]
246 + );
247 +
246 248 $this->end_controls_section();
247 249
248 250 $this->start_controls_section(
249 251 'section_style_image',
@@ -253,38 +255,8 @@
253 255 ]
254 256 );
255 257
256 258 $this->add_responsive_control(
257 - 'align',
258 - [
259 - 'label' => esc_html__( 'Alignment', 'elementor' ),
260 - 'type' => Controls_Manager::CHOOSE,
261 - 'options' => [
262 - 'start' => [
263 - 'title' => esc_html__( 'Start', 'elementor' ),
264 - 'icon' => 'eicon-text-align-left',
265 - ],
266 - 'center' => [
267 - 'title' => esc_html__( 'Center', 'elementor' ),
268 - 'icon' => 'eicon-text-align-center',
269 - ],
270 - 'end' => [
271 - 'title' => esc_html__( 'End', 'elementor' ),
272 - 'icon' => 'eicon-text-align-right',
273 - ],
274 - ],
275 - 'classes' => 'elementor-control-start-end',
276 - 'selectors_dictionary' => [
277 - 'left' => is_rtl() ? 'end' : 'start',
278 - 'right' => is_rtl() ? 'start' : 'end',
279 - ],
280 - 'selectors' => [
281 - '{{WRAPPER}}' => 'text-align: {{VALUE}};',
282 - ],
283 - ]
284 - );
285 -
286 - $this->add_responsive_control(
287 259 'width',
288 260 [
289 261 'label' => esc_html__( 'Width', 'elementor' ),
290 262 'type' => Controls_Manager::SLIDER,
@@ -387,9 +359,8 @@
387 359 '' => esc_html__( 'Default', 'elementor' ),
388 360 'fill' => esc_html__( 'Fill', 'elementor' ),
389 361 'cover' => esc_html__( 'Cover', 'elementor' ),
390 362 'contain' => esc_html__( 'Contain', 'elementor' ),
391 - 'scale-down' => esc_html__( 'Scale Down', 'elementor' ),
392 363 ],
393 364 'default' => '',
394 365 'selectors' => [
395 366 '{{WRAPPER}} img' => 'object-fit: {{VALUE}};',
@@ -417,10 +388,9 @@
417 388 'selectors' => [
418 389 '{{WRAPPER}} img' => 'object-position: {{VALUE}};',
419 390 ],
420 391 'condition' => [
421 - 'height[size]!' => '',
422 - 'object-fit' => [ 'cover', 'contain', 'scale-down' ],
392 + 'object-fit' => 'cover',
423 393 ],
424 394 ]
425 395 );
426 396
@@ -502,13 +472,12 @@
502 472
503 473 $this->add_control(
504 474 'background_hover_transition',
505 475 [
506 - 'label' => esc_html__( 'Transition Duration', 'elementor' ) . ' (s)',
476 + 'label' => esc_html__( 'Transition Duration', 'elementor' ),
507 477 'type' => Controls_Manager::SLIDER,
508 478 'range' => [
509 479 'px' => [
510 - 'min' => 0,
511 480 'max' => 3,
512 481 'step' => 0.1,
513 482 ],
514 483 ],
@@ -569,9 +538,8 @@
569 538 [
570 539 'label' => esc_html__( 'Caption', 'elementor' ),
571 540 'tab' => Controls_Manager::TAB_STYLE,
572 541 'condition' => [
573 - 'image[url]!' => '',
574 542 'caption_source!' => 'none',
575 543 ],
576 544 ]
577 545 );
@@ -581,10 +549,10 @@
581 549 [
582 550 'label' => esc_html__( 'Alignment', 'elementor' ),
583 551 'type' => Controls_Manager::CHOOSE,
584 552 'options' => [
585 - 'start' => [
586 - 'title' => esc_html__( 'Start', 'elementor' ),
553 + 'left' => [
554 + 'title' => esc_html__( 'Left', 'elementor' ),
587 555 'icon' => 'eicon-text-align-left',
588 556 ],
589 557 'center' => [
590 558 'title' => esc_html__( 'Center', 'elementor' ),
@@ -589,10 +557,10 @@
589 557 'center' => [
590 558 'title' => esc_html__( 'Center', 'elementor' ),
591 559 'icon' => 'eicon-text-align-center',
592 560 ],
593 - 'end' => [
594 - 'title' => esc_html__( 'End', 'elementor' ),
561 + 'right' => [
562 + 'title' => esc_html__( 'Right', 'elementor' ),
595 563 'icon' => 'eicon-text-align-right',
596 564 ],
597 565 'justify' => [
598 566 'title' => esc_html__( 'Justified', 'elementor' ),
@@ -598,13 +566,8 @@
598 566 'title' => esc_html__( 'Justified', 'elementor' ),
599 567 'icon' => 'eicon-text-align-justify',
600 568 ],
601 569 ],
602 - 'classes' => 'elementor-control-start-end',
603 - 'selectors_dictionary' => [
604 - 'left' => is_rtl() ? 'end' : 'start',
605 - 'right' => is_rtl() ? 'start' : 'end',
606 - ],
607 570 'default' => '',
608 571 'selectors' => [
609 572 '{{WRAPPER}} .widget-image-caption' => 'text-align: {{VALUE}};',
610 573 ],
@@ -660,24 +623,16 @@
660 623 'caption_space',
661 624 [
662 625 'label' => esc_html__( 'Spacing', 'elementor' ),
663 626 'type' => Controls_Manager::SLIDER,
664 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
665 627 'range' => [
666 628 'px' => [
629 + 'min' => 0,
667 630 'max' => 100,
668 631 ],
669 - 'em' => [
670 - 'min' => 0,
671 - 'max' => 10,
672 - ],
673 - 'rem' => [
674 - 'min' => 0,
675 - 'max' => 10,
676 - ],
677 632 ],
678 633 'selectors' => [
679 - '{{WRAPPER}} .widget-image-caption' => 'margin-block-start: {{SIZE}}{{UNIT}};',
634 + '{{WRAPPER}} .widget-image-caption' => 'margin-top: {{SIZE}}{{UNIT}};',
680 635 ],
681 636 ]
682 637 );
683 638
@@ -702,9 +657,9 @@
702 657 * Get the caption for current widget.
703 658 *
704 659 * @access private
705 660 * @since 2.3.0
706 - * @param array $settings
661 + * @param $settings
707 662 *
708 663 * @return string
709 664 */
710 665 private function get_caption( $settings ) {
@@ -735,8 +690,12 @@
735 690 if ( empty( $settings['image']['url'] ) ) {
736 691 return;
737 692 }
738 693
694 + if ( ! Plugin::$instance->experiments->is_feature_active( 'e_dom_optimization' ) ) {
695 + $this->add_render_attribute( 'wrapper', 'class', 'elementor-image' );
696 + }
697 +
739 698 $has_caption = $this->has_caption( $settings );
740 699
741 700 $link = $this->get_link_url( $settings );
742 701
@@ -752,8 +711,11 @@
752 711 if ( 'custom' !== $settings['link_to'] ) {
753 712 $this->add_lightbox_data_attributes( 'link', $settings['image']['id'], $settings['open_lightbox'] );
754 713 }
755 714 } ?>
715 + <?php if ( ! Plugin::$instance->experiments->is_feature_active( 'e_dom_optimization' ) ) { ?>
716 + <div <?php $this->print_render_attribute_string( 'wrapper' ); ?>>
717 + <?php } ?>
756 718 <?php if ( $has_caption ) : ?>
757 719 <figure class="wp-caption">
758 720 <?php endif; ?>
759 721 <?php if ( $link ) : ?>
@@ -770,67 +732,14 @@
770 732 <?php endif; ?>
771 733 <?php if ( $has_caption ) : ?>
772 734 </figure>
773 735 <?php endif; ?>
736 + <?php if ( ! Plugin::$instance->experiments->is_feature_active( 'e_dom_optimization' ) ) { ?>
737 + </div>
738 + <?php } ?>
774 739 <?php
775 740 }
776 741
777 - public function render_markdown(): string {
778 - $settings = $this->get_settings_for_display();
779 -
780 - if ( empty( $settings['image']['url'] ) ) {
781 - return '';
782 - }
783 -
784 - $url = esc_url( $settings['image']['url'] );
785 - $alt = $this->get_image_alt_text( $settings );
786 - $image_md = '![' . $alt . '](' . $url . ')';
787 -
788 - $link = $this->get_link_url( $settings );
789 -
790 - if ( ! empty( $link['url'] ) && $link['url'] !== $url ) {
791 - $image_md = '[' . $image_md . '](' . esc_url( $link['url'] ) . ')';
792 - }
793 -
794 - $caption = $this->get_visible_caption( $settings );
795 -
796 - if ( ! empty( $caption ) ) {
797 - $image_md .= "\n" . $caption;
798 - }
799 -
800 - return $image_md;
801 - }
802 -
803 - private function get_image_alt_text( array $settings ): string {
804 - if ( empty( $settings['image']['id'] ) ) {
805 - return '';
806 - }
807 -
808 - $attachment_id = $settings['image']['id'];
809 -
810 - $alt = get_post_meta( $attachment_id, '_wp_attachment_image_alt', true );
811 -
812 - if ( ! empty( $alt ) ) {
813 - return $alt;
814 - }
815 -
816 - $attachment = get_post( $attachment_id );
817 -
818 - if ( ! $attachment ) {
819 - return '';
820 - }
821 -
822 - return $attachment->post_title ?? '';
823 - }
824 -
825 - private function get_visible_caption( array $settings ): string {
826 - if ( ! $this->has_caption( $settings ) ) {
827 - return '';
828 - }
829 -
830 - return Utils::html_to_plain_text( $this->get_caption( $settings ) );
831 - }
832 -
833 742 /**
834 743 * Render image widget output in the editor.
835 744 *
836 745 * Written as a Backbone JavaScript template and used to generate the live preview.
@@ -887,9 +796,9 @@
887 796
888 797 var link_url;
889 798
890 799 if ( 'custom' === settings.link_to ) {
891 - link_url = settings.link?.url;
800 + link_url = settings.link.url;
892 801 }
893 802
894 803 if ( 'file' === settings.link_to ) {
895 804 link_url = settings.image.url;
@@ -894,8 +803,12 @@
894 803 if ( 'file' === settings.link_to ) {
895 804 link_url = settings.image.url;
896 805 }
897 806
807 + <?php if ( ! Plugin::$instance->experiments->is_feature_active( 'e_dom_optimization' ) ) { ?>
808 + #><div class="elementor-image{{ settings.shape ? ' elementor-image-shape-' + settings.shape : '' }}"><#
809 + <?php } ?>
810 +
898 811 var imgClass = '';
899 812
900 813 if ( '' !== settings.hover_animation ) {
901 814 imgClass = 'elementor-animation-' + settings.hover_animation;
@@ -905,9 +818,9 @@
905 818 #><figure class="wp-caption"><#
906 819 }
907 820
908 821 if ( link_url ) {
909 - #><a class="elementor-clickable" data-elementor-open-lightbox="{{ settings.open_lightbox }}" href="{{ elementor.helpers.sanitizeUrl( link_url ) }}"><#
822 + #><a class="elementor-clickable" data-elementor-open-lightbox="{{ settings.open_lightbox }}" href="{{ link_url }}"><#
910 823 }
911 824 #><img src="{{ image_url }}" class="{{ imgClass }}" /><#
912 825
913 826 if ( link_url ) {
@@ -920,8 +833,13 @@
920 833
921 834 if ( hasCaption() ) {
922 835 #></figure><#
923 836 }
837 +
838 + <?php if ( ! Plugin::$instance->experiments->is_feature_active( 'e_dom_optimization' ) ) { ?>
839 + #></div><#
840 + <?php } ?>
841 +
924 842 } #>
925 843 <?php
926 844 }
927 845