PluginProbe
Bricksable for Bricks Builder / 1.3.3
Bricksable for Bricks Builder v1.3.3
1.2.9 1.3.0 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.31 1.4.32 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 All 132 releases
bricksable / includes / elements / element-tilt-image.php

element-tilt-image.php in Bricksable for Bricks Builder 1.3.3, at includes/elements/element-tilt-image.php

746 lines 24.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly.
5 }
6
7 class Bricksable_Tilt_Image extends \Bricks\Element {
8 public $category = 'bricksable';
9 public $name = 'ba-tilt-image';
10 public $icon = 'ti-image';
11 public $css_selector = '.ba-tilt-image-wrapper img';
12 public $scripts = array( 'bricksableTiltImage' );
13
14 public function get_label() {
15 return esc_html__( 'Tilt Image', 'bricksable' );
16 }
17 public function set_control_groups() {
18 $this->control_groups['image'] = array(
19 'title' => esc_html__( 'Image', 'bricksable' ),
20 'tab' => 'content',
21 );
22 $this->control_groups['tilt_settings'] = array(
23 'title' => esc_html__( 'Tilt Settings', 'bricksable' ),
24 'tab' => 'content',
25 );
26 $this->control_groups['tilt_alignment'] = array(
27 'title' => esc_html__( 'Alignment', 'bricksable' ),
28 'tab' => 'style',
29 );
30 $this->control_groups['overlay'] = array(
31 'title' => esc_html__( 'Overlay Content', 'bricksable' ),
32 'tab' => 'content',
33 );
34 $this->control_groups['overlay_style'] = array(
35 'title' => esc_html__( 'Overlay', 'bricksable' ),
36 'tab' => 'style',
37 );
38 unset( $this->control_groups['_typography'] );
39 }
40
41 public function set_controls() {
42 $this->controls['_gradient']['css'][0]['selector'] = '.ba-tilt-image-wrapper';
43 $this->controls['_border']['css'][] =
44 array(
45 'property' => 'border',
46 'selector' => '.ba-tilt-image-wrapper:before',
47 );
48 array(
49 'property' => 'border',
50 'selector' => '.ba-tilt-image-wrapper img',
51 );
52
53 $this->controls['image'] = array(
54 'tab' => 'content',
55 'group' => 'image',
56 'type' => 'image',
57 );
58 // Link To.
59 $this->controls['linkToSeparator'] = array(
60 'tab' => 'content',
61 'group' => 'image',
62 'type' => 'separator',
63 'label' => esc_html__( 'Link To', 'bricksable' ),
64 );
65
66 $this->controls['link'] = array(
67 'tab' => 'content',
68 'group' => 'image',
69 'type' => 'select',
70 'options' => array(
71 'lightbox' => esc_html__( 'Lightbox', 'bricksable' ),
72 'attachment' => esc_html__( 'Attachment Page', 'bricksable' ),
73 'media' => esc_html__( 'Media File', 'bricksable' ),
74 'url' => esc_html__( 'Other (URL)', 'bricksable' ),
75 ),
76 'placeholder' => esc_html__( 'None', 'bricksable' ),
77 );
78
79 $this->controls['url'] = array(
80 'tab' => 'content',
81 'group' => 'image',
82 'label' => esc_html__( 'Link type', 'bricksable' ),
83 'type' => 'link',
84 'required' => array( 'link', '=', 'url' ),
85 );
86
87 // Alignment.
88 $this->controls['tilt_textAlign'] = array(
89 'tab' => 'style',
90 'group' => 'tilt_alignment',
91 'label' => esc_html__( 'Text align', 'bricksable' ),
92 'type' => 'text-align',
93 'css' => array(
94 array(
95 'property' => 'text-align',
96 'selector' => '.ba-tilt-image-wrapper .image-overlay-content',
97 ),
98 array(
99 'property' => 'text-align',
100 'selector' => '.ba-tilt-image-wrapper .ba-tilt-image-overlay-caption',
101 ),
102 ),
103 'default' => 'center',
104 'placeholder' => esc_html__( 'Center', 'bricksable' ),
105 'inline' => true,
106 );
107
108 $this->controls['tilt_verticalAlign'] = array(
109 'tab' => 'style',
110 'group' => 'tilt_alignment',
111 'label' => esc_html__( 'Vertical align', 'bricksable' ),
112 'type' => 'select',
113 'options' => $this->control_options['alignItems'],
114 'css' => array(
115 array(
116 'property' => 'align-items',
117 'selector' => '.ba-tilt-image-wrapper .image-overlay-wrapper',
118 ),
119 ),
120 'inline' => true,
121 'default' => 'center',
122 'placeholder' => esc_html__( 'Center', 'bricksable' ),
123 );
124
125 // Overlay.
126 $this->controls['imageOverlayShowHover'] = array(
127 'tab' => 'content',
128 'group' => 'overlay',
129 'label' => esc_html__( 'Only show overlay on hover', 'bricksable' ),
130 'type' => 'checkbox',
131 'inline' => true,
132 'description' => esc_html__( 'Set your overlay in the style tab (Gradient/Overlay).', 'bricksable' ),
133 );
134
135 // Title & Caption.
136
137 $this->controls['title_caption_separator'] = array(
138 'tab' => 'content',
139 'group' => 'overlay',
140 'type' => 'separator',
141 'label' => esc_html__( 'Title & Caption', 'bricksable' ),
142 );
143
144 $this->controls['overlay_title'] = array(
145 'tab' => 'content',
146 'group' => 'overlay',
147 'label' => esc_html__( 'Title Type', 'bricksable' ),
148 'type' => 'select',
149 'options' => array(
150 'none' => esc_html__( 'No title', 'bricksable' ),
151 'attachment' => esc_html__( 'Attachment', 'bricksable' ),
152 'custom' => esc_html__( 'Custom', 'bricksable' ),
153 ),
154 'inline' => true,
155 'placeholder' => esc_html__( 'No title', 'bricksable' ),
156 );
157
158 $this->controls['overlay_title_custom'] = array(
159 'tab' => 'content',
160 'group' => 'overlay',
161 'label' => esc_html__( 'Overlay Title', 'bricksable' ),
162 'type' => 'text',
163 'spellcheck' => true,
164 'inlineEditing' => true,
165 'hasDynamicData' => 'text',
166 'required' => array( 'overlay_title', '=', 'custom' ),
167 );
168
169 $this->controls['overlay_title_tag'] = array(
170 'tab' => 'content',
171 'group' => 'overlay',
172 'label' => esc_html__( 'Title Tag', 'bricksable' ),
173 'type' => 'select',
174 'options' => array(
175 'h1' => esc_html__( 'Heading 1 (h1)', 'bricksable' ),
176 'h2' => esc_html__( 'Heading 2 (h2)', 'bricksable' ),
177 'h3' => esc_html__( 'Heading 3 (h3)', 'bricksable' ),
178 'h4' => esc_html__( 'Heading 4 (h4)', 'bricksable' ),
179 'h5' => esc_html__( 'Heading 5 (h5)', 'bricksable' ),
180 'h6' => esc_html__( 'Heading 6 (h6)', 'bricksable' ),
181 ),
182 'clearable' => false,
183 'pasteStyles' => false,
184 'default' => 'h3',
185 'inline' => true,
186 'required' => array( 'overlay_title', '!=', 'none' ),
187 );
188
189 $this->controls['overlay_caption'] = array(
190 'tab' => 'content',
191 'group' => 'overlay',
192 'label' => esc_html__( 'Caption Type', 'bricksable' ),
193 'type' => 'select',
194 'options' => array(
195 'none' => esc_html__( 'No caption', 'bricksable' ),
196 'attachment' => esc_html__( 'Attachment', 'bricksable' ),
197 'custom' => esc_html__( 'Custom', 'bricksable' ),
198 ),
199 'inline' => true,
200 'placeholder' => esc_html__( 'No caption', 'bricksable' ),
201 );
202
203 $this->controls['overlay_caption_custom'] = array(
204 'tab' => 'content',
205 'group' => 'overlay',
206 'label' => esc_html__( 'Custom caption', 'bricksable' ),
207 'type' => 'text',
208 'placeholder' => esc_html__( 'Here goes your caption ...', 'bricksable' ),
209 'required' => array( 'overlay_caption', '=', 'custom' ),
210 );
211
212 $this->controls['overlayShowHover'] = array(
213 'tab' => 'content',
214 'group' => 'overlay',
215 'label' => esc_html__( 'Only show on hover', 'bricksable' ),
216 'type' => 'checkbox',
217 'inline' => true,
218 );
219
220 $this->controls['overlay_icon_separator'] = array(
221 'tab' => 'content',
222 'group' => 'overlay',
223 'label' => esc_html__( 'Icon', 'bricksable' ),
224 'type' => 'separator',
225 'inline' => true,
226 'small' => true,
227 );
228
229 $this->controls['overlay_icon'] = array(
230 'tab' => 'content',
231 'group' => 'overlay',
232 'label' => esc_html__( 'Icon', 'bricksable' ),
233 'type' => 'icon',
234 'inline' => true,
235 'small' => true,
236 );
237
238 $this->controls['overlay_translatez'] = array(
239 'tab' => 'style',
240 'group' => 'overlay_style',
241 'label' => esc_html__( 'Overlay Content Distance', 'bricksable' ),
242 'type' => 'slider',
243 'css' => array(
244 array(
245 'property' => 'transform:translateZ',
246 'selector' => '.image-overlay-wrapper',
247 ),
248 ),
249 'units' => array(
250 'px' => array(
251 'min' => 1,
252 'max' => 200,
253 'step' => 1,
254 ),
255 ),
256 'default' => '50px',
257 'description' => esc_html__( 'Adjust the distance between the image and the overlay content.', 'bricksable' ),
258 );
259
260 $this->controls['overlay_title_typography'] = array(
261 'tab' => 'style',
262 'group' => 'overlay_style',
263 'label' => esc_html__( 'Title Typography', 'bricksable' ),
264 'type' => 'typography',
265 'css' => array(
266 array(
267 'property' => 'font',
268 'selector' => '.ba-tilt-image-overlay-title',
269 ),
270 ),
271 'inline' => true,
272 'small' => true,
273 'required' => array( 'overlay_title', '!=', '' ),
274 );
275
276 $this->controls['overlay_caption_typography'] = array(
277 'tab' => 'style',
278 'group' => 'overlay_style',
279 'label' => esc_html__( 'Caption Typography', 'bricksable' ),
280 'type' => 'typography',
281 'css' => array(
282 array(
283 'property' => 'font',
284 'selector' => '.ba-tilt-image-caption',
285 ),
286 ),
287 'inline' => true,
288 'small' => true,
289 'required' => array( 'overlay_title', '!=', '' ),
290 );
291
292 $this->controls['overlay_style_icon_separator'] = array(
293 'tab' => 'style',
294 'group' => 'overlay_style',
295 'label' => esc_html__( 'Icon', 'bricksable' ),
296 'type' => 'separator',
297 'inline' => true,
298 'small' => true,
299 );
300
301 $this->controls['overlay_icon_border'] = array(
302 'tab' => 'style',
303 'group' => 'overlay_style',
304 'label' => esc_html__( 'Icon border', 'bricksable' ),
305 'type' => 'border',
306 'css' => array(
307 array(
308 'property' => 'border',
309 'selector' => '.image-overlay-wrapper .overlay-icon',
310 ),
311 ),
312 'inline' => true,
313 'small' => true,
314 'required' => array( 'overlay_icon', '!=', '' ),
315 );
316
317 $this->controls['overlay_icon_boxshadow'] = array(
318 'tab' => 'style',
319 'group' => 'overlay_style',
320 'label' => esc_html__( 'Icon box shadow', 'bricksable' ),
321 'type' => 'box-shadow',
322 'css' => array(
323 array(
324 'property' => 'box-shadow',
325 'selector' => '.image-overlay-wrapper .overlay-icon',
326 ),
327 ),
328 'inline' => true,
329 'small' => true,
330 'required' => array( 'overlay_icon', '!=', '' ),
331 );
332
333 $this->controls['overlay_icon_height'] = array(
334 'tab' => 'style',
335 'group' => 'overlay_style',
336 'label' => esc_html__( 'Icon height', 'bricksable' ),
337 'type' => 'number',
338 'unit' => 'px',
339 'css' => array(
340 array(
341 'property' => 'line-height',
342 'selector' => '.image-overlay-wrapper .overlay-icon',
343 ),
344 ),
345 'inline' => true,
346 'small' => true,
347 'required' => array( 'overlay_icon', '!=', '' ),
348 );
349
350 $this->controls['overlay_icon_width'] = array(
351 'tab' => 'style',
352 'group' => 'overlay_style',
353 'label' => esc_html__( 'Icon width', 'bricksable' ),
354 'type' => 'number',
355 'unit' => 'px',
356 'css' => array(
357 array(
358 'property' => 'width',
359 'selector' => '.image-overlay-wrapper .overlay-icon',
360 ),
361 ),
362 'inline' => true,
363 'small' => true,
364 'required' => array( 'overlay_icon', '!=', '' ),
365 );
366
367 $this->controls['overlay_icon_typography'] = array(
368 'tab' => 'style',
369 'group' => 'overlay_style',
370 'label' => esc_html__( 'Icon typography', 'bricksable' ),
371 'type' => 'typography',
372 'exclude' => array(
373 'font-family',
374 'font-weight',
375 'text-align',
376 'text-transform',
377 'line-height',
378 'letter-spacing',
379 ),
380 'css' => array(
381 array(
382 'property' => 'font',
383 'selector' => '.image-overlay-wrapper .overlay-icon',
384 ),
385 ),
386 'inline' => true,
387 'small' => true,
388 'required' => array( 'overlay_icon', '!=', '' ),
389 );
390
391 // Tilt Settings.
392 $this->controls['tilt_reverse'] = array(
393 'tab' => 'content',
394 'group' => 'tilt_settings',
395 'label' => esc_html__( 'Reverse', 'bricksable' ),
396 'type' => 'checkbox',
397 'inline' => true,
398 'description' => esc_html__( 'Reverse the tilt direction.', 'bricksable' ),
399 );
400 $this->controls['tilt_max'] = array(
401 'tab' => 'content',
402 'group' => 'tilt_settings',
403 'label' => esc_html__( 'Tilt rotation', 'bricksable' ),
404 'type' => 'slider',
405 'unitless' => true,
406 'min' => 10,
407 'max' => 100,
408 'step' => '1',
409 'default' => 40,
410 );
411
412 $this->controls['tilt_speed'] = array(
413 'tab' => 'content',
414 'group' => 'tilt_settings',
415 'label' => esc_html__( 'Tilt Speed', 'bricksable' ),
416 'type' => 'slider',
417 'unitless' => true,
418 'min' => 200,
419 'max' => 2000,
420 'step' => '100',
421 'default' => 1000,
422 );
423
424 $this->controls['tilt_perspective'] = array(
425 'tab' => 'content',
426 'group' => 'tilt_settings',
427 'label' => esc_html__( 'Tilt Perspective', 'bricksable' ),
428 'type' => 'slider',
429 'unitless' => true,
430 'min' => 200,
431 'max' => 1200,
432 'step' => '100',
433 'default' => 1000,
434 );
435
436 $this->controls['tilt_scale'] = array(
437 'tab' => 'content',
438 'group' => 'tilt_settings',
439 'label' => esc_html__( 'Tilt Scale', 'bricksable' ),
440 'type' => 'slider',
441 'unitless' => true,
442 'min' => 1,
443 'max' => 2,
444 'step' => '0.01',
445 'default' => 1,
446 );
447
448 $this->controls['tilt_glare'] = array(
449 'tab' => 'content',
450 'group' => 'tilt_settings',
451 'label' => esc_html__( 'Use glare', 'bricksable' ),
452 'type' => 'checkbox',
453 'inline' => true,
454 'description' => esc_html__( 'Setting this option will enable a glare effect.', 'bricksable' ),
455 );
456
457 $this->controls['tilt_max_glare'] = array(
458 'tab' => 'content',
459 'group' => 'tilt_settings',
460 'label' => esc_html__( 'Max Glare', 'bricksable' ),
461 'type' => 'slider',
462 'unitless' => true,
463 'min' => 0.1,
464 'max' => 1,
465 'step' => '0.01',
466 'default' => 0.8,
467 'required' => array( 'tilt_glare', '=', true ),
468 );
469 }
470
471 public function enqueue_scripts() {
472 if ( '' === get_option( 'bricksable_combine_minify_js' ) || false === get_option( 'bricksable_combine_minify_js' ) ) {
473 wp_enqueue_script( 'ba-tilt-image' );
474 wp_localize_script(
475 'ba-tilt-image',
476 'bricksableTiltImageData',
477 array(
478 'tiltImageInstances' => array(),
479 )
480 );
481 }
482 }
483
484 public function get_normalized_image_settings( $settings ) {
485 if ( ! isset( $settings['image'] ) ) {
486 $settings['image'] = array(
487 'id' => 0,
488 'url' => '',
489 );
490 return $settings;
491 }
492
493 $image = $settings['image'];
494
495 if ( isset( $image['useDynamicData']['name'] ) ) {
496 $images = $this->render_dynamic_data_tag( $image['useDynamicData']['name'] );
497 $image['id'] = empty( $images ) ? 0 : $images[0];
498 } else {
499 $image['id'] = isset( $image['id'] ) ? $image['id'] : 0;
500 }
501
502 // Image Size.
503 $image['size'] = isset( $image['size'] ) ? $settings['image']['size'] : BRICKS_DEFAULT_IMAGE_SIZE;
504
505 // Image URL.
506 if ( ! isset( $image['url'] ) ) {
507 $image['url'] = wp_get_attachment_image_url( $image['id'], $image['size'] );
508 }
509
510 $settings['image'] = $image;
511
512 return $settings;
513 }
514
515 public function render() {
516 $settings = $this->settings;
517 $settings = $this->get_normalized_image_settings( $settings );
518
519 $tilt_max = isset( $settings['tilt_max'] ) ? intval( $settings['tilt_max'] ) : 40;
520 $tilt_speed = isset( $settings['tilt_speed'] ) ? intval( $settings['tilt_speed'] ) : 1000;
521 $tilt_perspective = isset( $settings['tilt_perspective'] ) ? intval( $settings['tilt_perspective'] ) : 1000;
522 $tilt_scale = isset( $settings['tilt_scale'] ) ? round( $settings['tilt_scale'], 1 ) : 1;
523 $tilt_maxglare = isset( $settings['tilt_max_glare'] ) ? round( $settings['tilt_max_glare'], 1 ) : 1;
524 $tilt_reverse = isset( $settings['tilt_reverse'] ) ? true : false;
525
526 $tilt_options = array(
527 'max' => $tilt_max,
528 'speed' => $tilt_speed,
529 'perspective' => $tilt_perspective,
530 'scale' => $tilt_scale,
531 'glare' => $tilt_glare,
532 'max-glare' => $tilt_maxglare,
533 'reverse' => $tilt_reverse,
534 );
535
536 // Dynamic Data is empty.
537 if ( isset( $settings['image']['useDynamicData']['name'] ) ) {
538
539 if ( empty( $settings['image']['id'] ) ) {
540
541 if ( 'ACF' === $settings['image']['useDynamicData']['group'] && ! class_exists( 'ACF' ) ) {
542 $message = esc_html__( 'Can\'t render element, as the selected ACF field is not available. Please activate ACF or edit the element to select different data.', 'bricksable' );
543 } elseif ( '{featured_image}' === $settings['image']['useDynamicData']['name'] ) {
544 $message = esc_html__( 'No featured image set.', 'bricksable' );
545 } else {
546 /* translators: 1: Data 2: Dynamic Value */
547 $message = esc_html__( 'Dynamic Data %1$s (%2$s) is empty.', 'bricksable' );
548 }
549
550 $this->set_attribute( 'ba-no-image-wrapper', 'class', 'ba-tilt-image-wrapper' );
551 $this->set_attribute( 'ba-no-image-wrapper', 'id', esc_attr( 'ba-tilt-image-' . $this->id ) );
552 $this->set_attribute( 'ba-no-image-wrapper', 'data-ba-bricks-tilt-image-options', wp_json_encode( $tilt_options ) );
553
554 echo '<div ' . $this->render_attributes( 'ba-no-image-wrapper' ) . '>'; //phpcs:ignore
555
556 return $this->render_element_placeholder(
557 array(
558 'icon-class' => 'ti-image',
559 'text' => sprintf(
560 $message,
561 $settings['image']['useDynamicData']['label'],
562 $settings['image']['useDynamicData']['group']
563 ),
564 )
565 );
566 //phpcs:ignore
567 echo '</div>';
568
569 }
570 } else {
571 // Image id is empty or doesn't exist.
572 // No image.
573 if ( empty( $settings['image']['id'] ) ) {
574 $this->set_attribute( 'ba-no-image-wrapper', 'class', 'ba-tilt-image-wrapper' );
575 $this->set_attribute( 'ba-no-image-wrapper', 'id', esc_attr( 'ba-tilt-image-' . $this->id ) );
576 $this->set_attribute( 'ba-no-image-wrapper', 'data-ba-bricks-tilt-image-options', wp_json_encode( $tilt_options ) );
577
578 echo '<div ' . $this->render_attributes( 'ba-no-image-wrapper' ) . '>'; //phpcs:ignore
579
580 return $this->render_element_placeholder(
581 array(
582 'icon-class' => 'ti-image',
583 'text' => esc_html__( 'No image selected.', 'bricksable' ),
584 )
585 );
586 //phpcs:ignore
587 echo '</div>';
588 }
589
590 // Return if image ID does not exist.
591 if ( ! wp_get_attachment_image_src( $settings['image']['id'] ) ) {
592 return $this->render_element_placeholder(
593 array(
594 'icon-class' => 'ti-image',
595 /* translators: 1: Image ID */
596 'text' => sprintf( esc_html__( 'Image ID (%s) no longer exist. Please select another image.', 'bricksable' ), $settings['image']['id'] ),
597 )
598 );
599 }
600 }
601
602 // Render.
603 $image_atts = array();
604 $image_atts['id'] = 'image-' . $settings['image']['id'];
605
606 $image_wrapper_classes = array( 'ba-tilt-image-wrapper' );
607 $img_classes = array( 'post-thumbnail', 'css-filter' );
608
609 if ( isset( $settings['overlayShowHover'] ) ) {
610 $image_wrapper_classes[] = 'ba-tilt-image-show-hover';
611 }
612
613 if ( isset( $settings['imageOverlayShowHover'] ) ) {
614 $image_wrapper_classes[] = 'ba-tilt-image-overlay-hover';
615 }
616
617 if ( isset( $settings['link'] ) && 'lightbox' === $settings['link'] ) {
618 $image_wrapper_classes[] = 'bricks-lightbox';
619
620 $image_src = $settings['image']['id'] ? wp_get_attachment_image_src( $settings['image']['id'], 'full' ) : array(
621 \Bricks\Builder::get_template_placeholder_image(),
622 800,
623 600,
624 );
625 $this->set_attribute( 'image-wrapper', 'data-bricks-lightbox-source="' . $image_src[0] . '"' );
626 $this->set_attribute( 'image-wrapper', 'data-bricks-lightbox-width="' . $image_src[1] . '"' );
627 $this->set_attribute( 'image-wrapper', 'data-bricks-lightbox-height="' . $image_src[2] . '"' );
628 }
629
630 $img_classes[] = 'size-' . $settings['image']['size'];
631 $image_atts['class'] = join( ' ', $img_classes );
632
633 // Title.
634 $show_title = isset( $settings['overlay_title'] ) ? $settings['overlay_title'] : 'none';
635
636 if ( 'none' === $show_title ) {
637 $image_title = false;
638 } elseif ( 'custom' === $show_title && isset( $settings['overlay_title_custom'] ) ) {
639 $image_title = trim( $settings['overlay_title_custom'] );
640 } else {
641 $image_data = get_post( $settings['image']['id'] );
642 $image_title = $image_data ? $image_data->post_title : '';
643 }
644
645 // Caption.
646 $show_caption = isset( $settings['overlay_caption'] ) ? $settings['overlay_caption'] : 'none';
647
648 if ( 'none' === $show_caption ) {
649 $image_caption = false;
650 } elseif ( 'custom' === $show_caption && isset( $settings['overlay_caption_custom'] ) ) {
651 $image_caption = trim( $settings['overlay_caption_custom'] );
652 } else {
653 $image_data = get_post( $settings['image']['id'] );
654 $image_caption = $image_data ? $image_data->post_excerpt : '';
655 }
656
657 $this->set_attribute( 'image-wrapper', 'data-ba-bricks-tilt-image-options', wp_json_encode( $tilt_options ) );
658
659 $this->set_attribute( 'image-wrapper', 'class', $image_wrapper_classes );
660 $this->set_attribute( 'image-wrapper', 'id', esc_attr( 'ba-tilt-image-' . $this->id ) );
661 $this->set_attribute( 'image-wrapper', 'data-tilt' );
662 $this->set_attribute( 'image-wrapper', 'data-tilt-max="' . $tilt_max . '"' );
663 $this->set_attribute( 'image-wrapper', 'data-tilt-speed="' . $tilt_speed . '"' );
664 $this->set_attribute( 'image-wrapper', 'data-tilt-perspective="' . $tilt_perspective . '"' );
665 $this->set_attribute( 'image-wrapper', 'data-tilt-scale="' . $tilt_scale . '"' );
666 $this->set_attribute( 'image-wrapper', $settings['tilt_glare'] ? ' data-tilt-glare' : '' );
667 $this->set_attribute( 'image-wrapper', 'data-tilt-max-glare="' . $tilt_maxglare . '"' );
668 $this->set_attribute( 'image-wrapper', 'data-tilt-reverse="' . $tilt_reverse . '"' );
669
670 echo '<figure ' . $this->render_attributes( 'image-wrapper' ) . '>'; //phpcs:ignore
671
672 $close_a_tag = false;
673
674 if ( isset( $settings['link'] ) && 'media' === $settings['link'] ) {
675 $close_a_tag = true;
676
677 echo '<a href="' . esc_url( wp_get_attachment_url( $settings['image']['id'] ) ) . '" target="_blank">';
678 }
679
680 if ( isset( $settings['link'] ) && 'attachment' === $settings['link'] ) {
681 echo '<a href="' . esc_url( get_permalink( $settings['image']['id'] ) ) . '" target="_blank">';
682 }
683
684 if ( isset( $settings['link'] ) && 'url' === $settings['link'] && isset( $settings['url'] ) ) {
685 $close_a_tag = true;
686
687 // Link.
688 $this->set_link_attributes( 'a', $settings['url'] );
689
690 echo '<a ' . $this->render_attributes( 'a' ) . '>'; //phpcs:ignore
691 }
692
693 // Lazy load atts set via 'wp_get_attachment_image_attributes' filter.
694 if ( isset( $settings['image']['id'] ) ) {
695 echo wp_get_attachment_image( $settings['image']['id'], $settings['image']['size'], false, $image_atts );
696 } elseif ( ! empty( $settings['image']['url'] ) ) {
697 echo '<img src="' . esc_url( $settings['image']['url'] ) . '">';
698 }
699
700 if ( 'none' !== $show_title || 'none' !== $show_caption || isset( $settings['overlay_icon']['icon'] ) ) {
701 $overlay_title_tag = isset( $settings['overlay_title_tag'] ) ? esc_html( $settings['overlay_title_tag'] ) : 'h3';
702 $overlay_title_classes = array(
703 'ba-tilt-image-overlay-title',
704 'bricks-heading',
705 'bricks-heading-' . $overlay_title_tag,
706 );
707 $this->set_attribute( 'overlay_title', $overlay_title_tag );
708 $this->set_attribute( 'overlay_title', 'class', $overlay_title_classes );
709 if ( isset( $settings['overlay_icon']['icon'] ) ) {
710 $icon_classes = array( 'overlay-icon', $settings['overlay_icon']['icon'], 'icon' );
711 $this->set_attribute( 'overlay-icon-wrapper', 'class', 'overlay-icon-wrapper' );
712 $this->set_attribute( 'overlay-icon', 'class', $icon_classes );
713 }
714
715 $overlay_title_output = '<' . $this->render_attributes( 'overlay_title' ) . '>' . esc_html( $image_title ) . '</' . $overlay_title_tag . '>';
716
717 $this->set_attribute( 'image-overlay-wrapper', 'class', 'image-overlay-wrapper' );
718 $this->set_attribute( 'image-overlay-content', 'class', 'image-overlay-content' );
719
720 echo '<div ' . $this->render_attributes( 'image-overlay-wrapper' ) . '>'; //phpcs:ignore
721 echo '<div ' . $this->render_attributes( 'image-overlay-content' ) . '>'; //phpcs:ignore
722 if ( isset( $settings['overlay_icon']['icon'] ) ) {
723 echo '<div ' . $this->render_attributes( 'overlay-icon-wrapper' ) . '>'; //phpcs:ignore
724 echo '<i ' . $this->render_attributes( 'overlay-icon' ) . '></i>'; //phpcs:ignore
725 echo '</div>';
726 }
727 if ( $image_title ) {
728 //phpcs:ignore
729 echo $overlay_title_output;
730 }
731 if ( $image_caption ) {
732 echo '<figcaption class="ba-tilt-image-overlay-caption">' . esc_html( $image_caption ) . '</figcaption>';
733 }
734 echo '</div>';
735 echo '</div>';
736 }
737
738 if ( $close_a_tag ) {
739 echo '</a>';
740 }
741
742 echo '</figure>';
743
744 }
745 }
746