PluginProbe
Elementor Website Builder – more than just a page builder / 3.23.0-dev6
Elementor Website Builder – more than just a page builder v3.23.0-dev6
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.23.0-dev6, at includes/widgets/image.php

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