Using Advanced Custom Fields (ACF), I usually use the following code to display a specific field with a specific thumbnail size (using image ID):
$image = get_field('field_name_here');
$size = 'thumbnail_size_here';
if( $image ) {
echo wp_get_attachment_image( $image, $size );
}
However, when I tried to use this code in a repeater field, it just spits out numbers.
I have tried updating the above code to:
$image = the_sub_field('field_name_here');
$size = 'thumbnail_size_here';
if( $image ) {
echo wp_get_attachment_image( $image, $size );
}
However, this does not work, again it just spits out numbers. The full code would be like this:
<?php if(get_field('example_repeater_field')): ?>
<ul>
<?php while(has_sub_field('example_repeater_field')): ?>
<li>
<?php
$image = the_sub_field('field_name_here');
$size = 'thumbnail_size_here';
if( $image ) {
echo wp_get_attachment_image( $image, $size );
} ?>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
I have read the info on the ACF website but cannot see anything that related to custom thumbnail sizes.
Has anyone come across this before and found a solution?