PluginProbe
Getwid – Gutenberg Blocks / 2.0.12
Getwid – Gutenberg Blocks v2.0.12
3.0.2 3.0.1 3.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.2.0 trunk 1.8.7 1.9.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9
getwid / includes / templates / template-parts / acf / background-image.php

background-image.php in Getwid – Gutenberg Blocks 2.0.12, at includes/templates/template-parts/acf/background-image.php

54 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 //extract styles & classes
4 extract( $extra_attr );
5
6 if ( empty( $attributes[ 'customField' ] ) ) {
7 return;
8 }
9
10 ?>
11
12 <div class="<?php echo esc_attr( $wrapper_class ); ?>" <?php if ( ! empty( $wrapper_style ) ) { ?> style="<?php echo esc_attr( $wrapper_style ); ?>"<?php } ?>>
13 <?php
14
15 $field = get_field_object( $attributes[ 'customField' ], get_the_ID() );
16
17 if ( $field ) :
18 $img_id = '';
19 $fieldType = $field[ 'type' ];
20 $filedFormat = $field[ 'return_format' ];
21
22 switch ( $fieldType ) {
23 case 'image' :
24 $image = get_field( $attributes[ 'customField' ], get_the_ID() );
25
26 switch ( $filedFormat ) {
27 case 'id' :
28 $img_id = $image;
29
30 break;
31 case 'url' :
32 $img_id = attachment_url_to_postid( $image );
33
34 break;
35 case 'array' :
36 $img_id = $image[ 'ID' ];
37
38 break;
39 }
40
41 break;
42 }
43
44 ?>
45 <div class="<?php echo esc_attr( $block_name ); ?>__image" style="background-image: url(<?php echo esc_url(wp_get_attachment_image_url($img_id, $imageSize))?>);"></div>
46 <div <?php if ( !empty($foreground_style) ) { ?> style="<?php echo esc_attr($foreground_style); ?>" <?php } ?> class="<?php echo esc_attr($foreground_class);?>"></div>
47 <div <?php if ( !empty($content_container_style) ) { ?> style="<?php echo esc_attr($content_container_style); ?>" <?php } ?> class="<?php echo esc_attr($content_container_class);?>">
48 <?php echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
49 </div>
50 <?php
51 endif;
52 ?>
53 </div>
54