PluginProbe
Elementor Website Builder – more than just a page builder / 3.16.0-dev1
Elementor Website Builder – more than just a page builder v3.16.0-dev1
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 / includes / widgets / image.php

image.php in Elementor Website Builder – more than just a page builder 3.16.0-dev1, at includes/widgets/image.php

873 lines 19.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
9 use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
10
11 /**
12 * Elementor image widget.
13 *
14 * Elementor widget that displays an image into the page.
15 *
16 * @since 1.0.0
17 */
18 class Widget_Image extends Widget_Base {
19
20 /**
21 * Get widget name.
22 *
23 * Retrieve image widget name.
24 *
25 * @since 1.0.0
26 * @access public
27 *
28 * @return string Widget name.
29 */
30 public function get_name() {
31 return 'image';
32 }
33
34 /**
35 * Get widget title.
36 *
37 * Retrieve image widget title.
38 *
39 * @since 1.0.0
40 * @access public
41 *
42 * @return string Widget title.
43 */
44 public function get_title() {
45 return esc_html__( 'Image', 'elementor' );
46 }
47
48 /**
49 * Get widget icon.
50 *
51 * Retrieve image widget icon.
52 *
53 * @since 1.0.0
54 * @access public
55 *
56 * @return string Widget icon.
57 */
58 public function get_icon() {
59 return 'eicon-image';
60 }
61
62 /**
63 * Get widget categories.
64 *
65 * Retrieve the list of categories the image widget belongs to.
66 *
67 * Used to determine where to display the widget in the editor.
68 *
69 * @since 2.0.0
70 * @access public
71 *
72 * @return array Widget categories.
73 */
74 public function get_categories() {
75 return [ 'basic' ];
76 }
77
78 /**
79 * Get widget keywords.
80 *
81 * Retrieve the list of keywords the widget belongs to.
82 *
83 * @since 2.1.0
84 * @access public
85 *
86 * @return array Widget keywords.
87 */
88 public function get_keywords() {
89 return [ 'image', 'photo', 'visual' ];
90 }
91
92 /**
93 * Register image widget controls.
94 *
95 * Adds different input fields to allow the user to change and customize the widget settings.
96 *
97 * @since 3.1.0
98 * @access protected
99 */
100 protected function register_controls() {
101 $this->start_controls_section(
102 'section_image',
103 [
104 'label' => esc_html__( 'Image', 'elementor' ),
105 ]
106 );
107
108 $this->add_control(
109 'image',
110 [
111 'label' => esc_html__( 'Choose Image', 'elementor' ),
112 'type' => Controls_Manager::MEDIA,
113 'dynamic' => [
114 'active' => true,
115 ],
116 'default' => [
117 'url' => Utils::get_placeholder_image_src(),
118 ],
119 ]
120 );
121
122 $this->add_group_control(
123 Group_Control_Image_Size::get_type(),
124 [
125 'name' => 'image', // Usage: `{name}_size` and `{name}_custom_dimension`, in this case `image_size` and `image_custom_dimension`.
126 'default' => 'large',
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 ],
149 ],
150 'selectors' => [
151 '{{WRAPPER}}' => 'text-align: {{VALUE}};',
152 ],
153 ]
154 );
155
156 $this->add_control(
157 'caption_source',
158 [
159 'label' => esc_html__( 'Caption', 'elementor' ),
160 'type' => Controls_Manager::SELECT,
161 'options' => [
162 'none' => esc_html__( 'None', 'elementor' ),
163 'attachment' => esc_html__( 'Attachment Caption', 'elementor' ),
164 'custom' => esc_html__( 'Custom Caption', 'elementor' ),
165 ],
166 'default' => 'none',
167 ]
168 );
169
170 $this->add_control(
171 'caption',
172 [
173 'label' => esc_html__( 'Custom Caption', 'elementor' ),
174 'type' => Controls_Manager::TEXT,
175 'default' => '',
176 'placeholder' => esc_html__( 'Enter your image caption', 'elementor' ),
177 'condition' => [
178 'caption_source' => 'custom',
179 ],
180 'dynamic' => [
181 'active' => true,
182 ],
183 ]
184 );
185
186 $this->add_control(
187 'link_to',
188 [
189 'label' => esc_html__( 'Link', 'elementor' ),
190 'type' => Controls_Manager::SELECT,
191 'default' => 'none',
192 'options' => [
193 'none' => esc_html__( 'None', 'elementor' ),
194 'file' => esc_html__( 'Media File', 'elementor' ),
195 'custom' => esc_html__( 'Custom URL', 'elementor' ),
196 ],
197 ]
198 );
199
200 $this->add_control(
201 'link',
202 [
203 'label' => esc_html__( 'Link', 'elementor' ),
204 'type' => Controls_Manager::URL,
205 'dynamic' => [
206 'active' => true,
207 ],
208 'condition' => [
209 'link_to' => 'custom',
210 ],
211 'show_label' => false,
212 ]
213 );
214
215 $this->add_control(
216 'open_lightbox',
217 [
218 'label' => esc_html__( 'Lightbox', 'elementor' ),
219 'type' => Controls_Manager::SELECT,
220 'description' => sprintf(
221 /* translators: 1: Link open tag, 2: Link close tag. */
222 esc_html__( 'Manage your site’s lightbox settings in the %1$sLightbox panel%2$s.', 'elementor' ),
223 '<a href="javascript: $e.run( \'panel/global/open\' ).then( () => $e.route( \'panel/global/settings-lightbox\' ) )">',
224 '</a>'
225 ),
226 'default' => 'default',
227 'options' => [
228 'default' => esc_html__( 'Default', 'elementor' ),
229 'yes' => esc_html__( 'Yes', 'elementor' ),
230 'no' => esc_html__( 'No', 'elementor' ),
231 ],
232 'condition' => [
233 'link_to' => 'file',
234 ],
235 ]
236 );
237
238 $this->add_control(
239 'view',
240 [
241 'label' => esc_html__( 'View', 'elementor' ),
242 'type' => Controls_Manager::HIDDEN,
243 'default' => 'traditional',
244 ]
245 );
246
247 $this->end_controls_section();
248
249 $this->start_controls_section(
250 'section_style_image',
251 [
252 'label' => esc_html__( 'Image', 'elementor' ),
253 'tab' => Controls_Manager::TAB_STYLE,
254 ]
255 );
256
257 $this->add_responsive_control(
258 'width',
259 [
260 'label' => esc_html__( 'Width', 'elementor' ),
261 'type' => Controls_Manager::SLIDER,
262 'default' => [
263 'unit' => '%',
264 ],
265 'tablet_default' => [
266 'unit' => '%',
267 ],
268 'mobile_default' => [
269 'unit' => '%',
270 ],
271 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
272 'range' => [
273 '%' => [
274 'min' => 1,
275 'max' => 100,
276 ],
277 'px' => [
278 'min' => 1,
279 'max' => 1000,
280 ],
281 'vw' => [
282 'min' => 1,
283 'max' => 100,
284 ],
285 ],
286 'selectors' => [
287 '{{WRAPPER}} img' => 'width: {{SIZE}}{{UNIT}};',
288 ],
289 ]
290 );
291
292 $this->add_responsive_control(
293 'space',
294 [
295 'label' => esc_html__( 'Max Width', 'elementor' ),
296 'type' => Controls_Manager::SLIDER,
297 'default' => [
298 'unit' => '%',
299 ],
300 'tablet_default' => [
301 'unit' => '%',
302 ],
303 'mobile_default' => [
304 'unit' => '%',
305 ],
306 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
307 'range' => [
308 '%' => [
309 'min' => 1,
310 'max' => 100,
311 ],
312 'px' => [
313 'min' => 1,
314 'max' => 1000,
315 ],
316 'vw' => [
317 'min' => 1,
318 'max' => 100,
319 ],
320 ],
321 'selectors' => [
322 '{{WRAPPER}} img' => 'max-width: {{SIZE}}{{UNIT}};',
323 ],
324 ]
325 );
326
327 $this->add_responsive_control(
328 'height',
329 [
330 'label' => esc_html__( 'Height', 'elementor' ),
331 'type' => Controls_Manager::SLIDER,
332 'size_units' => [ 'px', '%', 'em', 'rem', 'vh', 'custom' ],
333 'range' => [
334 'px' => [
335 'min' => 1,
336 'max' => 500,
337 ],
338 'vh' => [
339 'min' => 1,
340 'max' => 100,
341 ],
342 ],
343 'selectors' => [
344 '{{WRAPPER}} img' => 'height: {{SIZE}}{{UNIT}};',
345 ],
346 ]
347 );
348
349 $this->add_responsive_control(
350 'object-fit',
351 [
352 'label' => esc_html__( 'Object Fit', 'elementor' ),
353 'type' => Controls_Manager::SELECT,
354 'condition' => [
355 'height[size]!' => '',
356 ],
357 'options' => [
358 '' => esc_html__( 'Default', 'elementor' ),
359 'fill' => esc_html__( 'Fill', 'elementor' ),
360 'cover' => esc_html__( 'Cover', 'elementor' ),
361 'contain' => esc_html__( 'Contain', 'elementor' ),
362 ],
363 'default' => '',
364 'selectors' => [
365 '{{WRAPPER}} img' => 'object-fit: {{VALUE}};',
366 ],
367 ]
368 );
369
370 $this->add_responsive_control(
371 'object-position',
372 [
373 'label' => esc_html__( 'Object Position', 'elementor' ),
374 'type' => Controls_Manager::SELECT,
375 'options' => [
376 'center center' => esc_html__( 'Center Center', 'elementor' ),
377 'center left' => esc_html__( 'Center Left', 'elementor' ),
378 'center right' => esc_html__( 'Center Right', 'elementor' ),
379 'top center' => esc_html__( 'Top Center', 'elementor' ),
380 'top left' => esc_html__( 'Top Left', 'elementor' ),
381 'top right' => esc_html__( 'Top Right', 'elementor' ),
382 'bottom center' => esc_html__( 'Bottom Center', 'elementor' ),
383 'bottom left' => esc_html__( 'Bottom Left', 'elementor' ),
384 'bottom right' => esc_html__( 'Bottom Right', 'elementor' ),
385 ],
386 'default' => 'center center',
387 'selectors' => [
388 '{{WRAPPER}} img' => 'object-position: {{VALUE}};',
389 ],
390 'condition' => [
391 'object-fit' => 'cover',
392 ],
393 ]
394 );
395
396 $this->add_control(
397 'separator_panel_style',
398 [
399 'type' => Controls_Manager::DIVIDER,
400 'style' => 'thick',
401 ]
402 );
403
404 $this->start_controls_tabs( 'image_effects' );
405
406 $this->start_controls_tab( 'normal',
407 [
408 'label' => esc_html__( 'Normal', 'elementor' ),
409 ]
410 );
411
412 $this->add_control(
413 'opacity',
414 [
415 'label' => esc_html__( 'Opacity', 'elementor' ),
416 'type' => Controls_Manager::SLIDER,
417 'range' => [
418 'px' => [
419 'max' => 1,
420 'min' => 0.10,
421 'step' => 0.01,
422 ],
423 ],
424 'selectors' => [
425 '{{WRAPPER}} img' => 'opacity: {{SIZE}};',
426 ],
427 ]
428 );
429
430 $this->add_group_control(
431 Group_Control_Css_Filter::get_type(),
432 [
433 'name' => 'css_filters',
434 'selector' => '{{WRAPPER}} img',
435 ]
436 );
437
438 $this->end_controls_tab();
439
440 $this->start_controls_tab( 'hover',
441 [
442 'label' => esc_html__( 'Hover', 'elementor' ),
443 ]
444 );
445
446 $this->add_control(
447 'opacity_hover',
448 [
449 'label' => esc_html__( 'Opacity', 'elementor' ),
450 'type' => Controls_Manager::SLIDER,
451 'range' => [
452 'px' => [
453 'max' => 1,
454 'min' => 0.10,
455 'step' => 0.01,
456 ],
457 ],
458 'selectors' => [
459 '{{WRAPPER}}:hover img' => 'opacity: {{SIZE}};',
460 ],
461 ]
462 );
463
464 $this->add_group_control(
465 Group_Control_Css_Filter::get_type(),
466 [
467 'name' => 'css_filters_hover',
468 'selector' => '{{WRAPPER}}:hover img',
469 ]
470 );
471
472 $this->add_control(
473 'background_hover_transition',
474 [
475 'label' => esc_html__( 'Transition Duration', 'elementor' ),
476 'type' => Controls_Manager::SLIDER,
477 'range' => [
478 'px' => [
479 'max' => 3,
480 'step' => 0.1,
481 ],
482 ],
483 'selectors' => [
484 '{{WRAPPER}} img' => 'transition-duration: {{SIZE}}s',
485 ],
486 ]
487 );
488
489 $this->add_control(
490 'hover_animation',
491 [
492 'label' => esc_html__( 'Hover Animation', 'elementor' ),
493 'type' => Controls_Manager::HOVER_ANIMATION,
494 ]
495 );
496
497 $this->end_controls_tab();
498
499 $this->end_controls_tabs();
500
501 $this->add_group_control(
502 Group_Control_Border::get_type(),
503 [
504 'name' => 'image_border',
505 'selector' => '{{WRAPPER}} img',
506 'separator' => 'before',
507 ]
508 );
509
510 $this->add_responsive_control(
511 'image_border_radius',
512 [
513 'label' => esc_html__( 'Border Radius', 'elementor' ),
514 'type' => Controls_Manager::DIMENSIONS,
515 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
516 'selectors' => [
517 '{{WRAPPER}} img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
518 ],
519 ]
520 );
521
522 $this->add_group_control(
523 Group_Control_Box_Shadow::get_type(),
524 [
525 'name' => 'image_box_shadow',
526 'exclude' => [
527 'box_shadow_position',
528 ],
529 'selector' => '{{WRAPPER}} img',
530 ]
531 );
532
533 $this->end_controls_section();
534
535 $this->start_controls_section(
536 'section_style_caption',
537 [
538 'label' => esc_html__( 'Caption', 'elementor' ),
539 'tab' => Controls_Manager::TAB_STYLE,
540 'condition' => [
541 'caption_source!' => 'none',
542 ],
543 ]
544 );
545
546 $this->add_responsive_control(
547 'caption_align',
548 [
549 'label' => esc_html__( 'Alignment', 'elementor' ),
550 'type' => Controls_Manager::CHOOSE,
551 'options' => [
552 'left' => [
553 'title' => esc_html__( 'Left', 'elementor' ),
554 'icon' => 'eicon-text-align-left',
555 ],
556 'center' => [
557 'title' => esc_html__( 'Center', 'elementor' ),
558 'icon' => 'eicon-text-align-center',
559 ],
560 'right' => [
561 'title' => esc_html__( 'Right', 'elementor' ),
562 'icon' => 'eicon-text-align-right',
563 ],
564 'justify' => [
565 'title' => esc_html__( 'Justified', 'elementor' ),
566 'icon' => 'eicon-text-align-justify',
567 ],
568 ],
569 'default' => '',
570 'selectors' => [
571 '{{WRAPPER}} .widget-image-caption' => 'text-align: {{VALUE}};',
572 ],
573 ]
574 );
575
576 $this->add_control(
577 'text_color',
578 [
579 'label' => esc_html__( 'Text Color', 'elementor' ),
580 'type' => Controls_Manager::COLOR,
581 'default' => '',
582 'selectors' => [
583 '{{WRAPPER}} .widget-image-caption' => 'color: {{VALUE}};',
584 ],
585 'global' => [
586 'default' => Global_Colors::COLOR_TEXT,
587 ],
588 ]
589 );
590
591 $this->add_control(
592 'caption_background_color',
593 [
594 'label' => esc_html__( 'Background Color', 'elementor' ),
595 'type' => Controls_Manager::COLOR,
596 'selectors' => [
597 '{{WRAPPER}} .widget-image-caption' => 'background-color: {{VALUE}};',
598 ],
599 ]
600 );
601
602 $this->add_group_control(
603 Group_Control_Typography::get_type(),
604 [
605 'name' => 'caption_typography',
606 'selector' => '{{WRAPPER}} .widget-image-caption',
607 'global' => [
608 'default' => Global_Typography::TYPOGRAPHY_TEXT,
609 ],
610 ]
611 );
612
613 $this->add_group_control(
614 Group_Control_Text_Shadow::get_type(),
615 [
616 'name' => 'caption_text_shadow',
617 'selector' => '{{WRAPPER}} .widget-image-caption',
618 ]
619 );
620
621 $this->add_responsive_control(
622 'caption_space',
623 [
624 'label' => esc_html__( 'Spacing', 'elementor' ),
625 'type' => Controls_Manager::SLIDER,
626 'range' => [
627 'px' => [
628 'min' => 0,
629 'max' => 100,
630 ],
631 ],
632 'selectors' => [
633 '{{WRAPPER}} .widget-image-caption' => 'margin-top: {{SIZE}}{{UNIT}};',
634 ],
635 ]
636 );
637
638 $this->end_controls_section();
639 }
640
641 /**
642 * Check if the current widget has caption
643 *
644 * @access private
645 * @since 2.3.0
646 *
647 * @param array $settings
648 *
649 * @return boolean
650 */
651 private function has_caption( $settings ) {
652 return ( ! empty( $settings['caption_source'] ) && 'none' !== $settings['caption_source'] );
653 }
654
655 /**
656 * Get the caption for current widget.
657 *
658 * @access private
659 * @since 2.3.0
660 * @param $settings
661 *
662 * @return string
663 */
664 private function get_caption( $settings ) {
665 $caption = '';
666 if ( ! empty( $settings['caption_source'] ) ) {
667 switch ( $settings['caption_source'] ) {
668 case 'attachment':
669 $caption = wp_get_attachment_caption( $settings['image']['id'] );
670 break;
671 case 'custom':
672 $caption = ! Utils::is_empty( $settings['caption'] ) ? $settings['caption'] : '';
673 }
674 }
675 return $caption;
676 }
677
678 /**
679 * Render image widget output on the frontend.
680 *
681 * Written in PHP and used to generate the final HTML.
682 *
683 * @since 1.0.0
684 * @access protected
685 */
686 protected function render() {
687 $settings = $this->get_settings_for_display();
688
689 if ( empty( $settings['image']['url'] ) ) {
690 return;
691 }
692
693 if ( ! Plugin::$instance->experiments->is_feature_active( 'e_dom_optimization' ) ) {
694 $this->add_render_attribute( 'wrapper', 'class', 'elementor-image' );
695 }
696
697 $has_caption = $this->has_caption( $settings );
698
699 $link = $this->get_link_url( $settings );
700
701 if ( $link ) {
702 $this->add_link_attributes( 'link', $link );
703
704 if ( Plugin::$instance->editor->is_edit_mode() ) {
705 $this->add_render_attribute( 'link', [
706 'class' => 'elementor-clickable',
707 ] );
708 }
709
710 if ( 'custom' !== $settings['link_to'] ) {
711 $this->add_lightbox_data_attributes( 'link', $settings['image']['id'], $settings['open_lightbox'] );
712 }
713 } ?>
714 <?php if ( ! Plugin::$instance->experiments->is_feature_active( 'e_dom_optimization' ) ) { ?>
715 <div <?php $this->print_render_attribute_string( 'wrapper' ); ?>>
716 <?php } ?>
717 <?php if ( $has_caption ) : ?>
718 <figure class="wp-caption">
719 <?php endif; ?>
720 <?php if ( $link ) : ?>
721 <a <?php $this->print_render_attribute_string( 'link' ); ?>>
722 <?php endif; ?>
723 <?php Group_Control_Image_Size::print_attachment_image_html( $settings ); ?>
724 <?php if ( $link ) : ?>
725 </a>
726 <?php endif; ?>
727 <?php if ( $has_caption ) : ?>
728 <figcaption class="widget-image-caption wp-caption-text"><?php
729 echo wp_kses_post( $this->get_caption( $settings ) );
730 ?></figcaption>
731 <?php endif; ?>
732 <?php if ( $has_caption ) : ?>
733 </figure>
734 <?php endif; ?>
735 <?php if ( ! Plugin::$instance->experiments->is_feature_active( 'e_dom_optimization' ) ) { ?>
736 </div>
737 <?php } ?>
738 <?php
739 }
740
741 /**
742 * Render image widget output in the editor.
743 *
744 * Written as a Backbone JavaScript template and used to generate the live preview.
745 *
746 * @since 2.9.0
747 * @access protected
748 */
749 protected function content_template() {
750 ?>
751 <# if ( settings.image.url ) {
752 var image = {
753 id: settings.image.id,
754 url: settings.image.url,
755 size: settings.image_size,
756 dimension: settings.image_custom_dimension,
757 model: view.getEditModel()
758 };
759
760 var image_url = elementor.imagesManager.getImageUrl( image );
761
762 if ( ! image_url ) {
763 return;
764 }
765
766 var hasCaption = function() {
767 if( ! settings.caption_source || 'none' === settings.caption_source ) {
768 return false;
769 }
770 return true;
771 }
772
773 var ensureAttachmentData = function( id ) {
774 if ( 'undefined' === typeof wp.media.attachment( id ).get( 'caption' ) ) {
775 wp.media.attachment( id ).fetch().then( function( data ) {
776 view.render();
777 } );
778 }
779 }
780
781 var getAttachmentCaption = function( id ) {
782 if ( ! id ) {
783 return '';
784 }
785 ensureAttachmentData( id );
786 return wp.media.attachment( id ).get( 'caption' );
787 }
788
789 var getCaption = function() {
790 if ( ! hasCaption() ) {
791 return '';
792 }
793 return 'custom' === settings.caption_source ? settings.caption : getAttachmentCaption( settings.image.id );
794 }
795
796 var link_url;
797
798 if ( 'custom' === settings.link_to ) {
799 link_url = settings.link.url;
800 }
801
802 if ( 'file' === settings.link_to ) {
803 link_url = settings.image.url;
804 }
805
806 <?php if ( ! Plugin::$instance->experiments->is_feature_active( 'e_dom_optimization' ) ) { ?>
807 #><div class="elementor-image{{ settings.shape ? ' elementor-image-shape-' + settings.shape : '' }}"><#
808 <?php } ?>
809
810 var imgClass = '';
811
812 if ( '' !== settings.hover_animation ) {
813 imgClass = 'elementor-animation-' + settings.hover_animation;
814 }
815
816 if ( hasCaption() ) {
817 #><figure class="wp-caption"><#
818 }
819
820 if ( link_url ) {
821 #><a class="elementor-clickable" data-elementor-open-lightbox="{{ settings.open_lightbox }}" href="{{ link_url }}"><#
822 }
823 #><img src="{{ image_url }}" class="{{ imgClass }}" /><#
824
825 if ( link_url ) {
826 #></a><#
827 }
828
829 if ( hasCaption() ) {
830 #><figcaption class="widget-image-caption wp-caption-text">{{{ getCaption() }}}</figcaption><#
831 }
832
833 if ( hasCaption() ) {
834 #></figure><#
835 }
836
837 <?php if ( ! Plugin::$instance->experiments->is_feature_active( 'e_dom_optimization' ) ) { ?>
838 #></div><#
839 <?php } ?>
840
841 } #>
842 <?php
843 }
844
845 /**
846 * Retrieve image widget link URL.
847 *
848 * @since 3.11.0
849 * @access protected
850 *
851 * @param array $settings
852 *
853 * @return array|string|false An array/string containing the link URL, or false if no link.
854 */
855 protected function get_link_url( $settings ) {
856 if ( 'none' === $settings['link_to'] ) {
857 return false;
858 }
859
860 if ( 'custom' === $settings['link_to'] ) {
861 if ( empty( $settings['link']['url'] ) ) {
862 return false;
863 }
864
865 return $settings['link'];
866 }
867
868 return [
869 'url' => $settings['image']['url'],
870 ];
871 }
872 }
873