PluginProbe
Getwid – Gutenberg Blocks / 2.0.5
Getwid – Gutenberg Blocks v2.0.5
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 / image.php

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

56 lines 1.3 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 ); ?>">
13 <?php if ( $attributes[ 'linkTo' ] == 'post' ) { ?>
14 <a href="<?php echo esc_url( get_permalink() ); ?>">
15 <?php } ?>
16 <?php
17
18 $field = get_field_object( $attributes[ 'customField' ], get_the_ID() );
19
20 if ( $field ) :
21 $output = '';
22 $fieldType = $field[ 'type' ];
23 $filedFormat = $field[ 'return_format' ];
24
25 switch ( $fieldType ) {
26 case 'image' :
27 $image = get_field( $attributes[ 'customField' ], get_the_ID() );
28
29 switch ( $filedFormat ) {
30 case 'id' :
31 $output = wp_get_attachment_image( $image, $imageSize );
32
33 break;
34 case 'url' :
35 $img_id = attachment_url_to_postid( $image );
36 $output = wp_get_attachment_image( $img_id, $imageSize );
37
38 break;
39 case 'array' :
40 $img_id = $image[ 'ID' ];
41 $output = wp_get_attachment_image( $img_id, $imageSize );
42
43 break;
44 }
45
46 break;
47 }
48
49 echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
50 endif;
51 ?>
52 <?php if ($attributes['linkTo'] == 'post'){ ?>
53 </a>
54 <?php } ?>
55 </div>
56