For a custom WP theme I am creating I am using ACF. I need to have a repeater that outputs images. I have it set to image object and using the correct code. In fact I tried it without a repeater and it works perfectly. Its only within the repeater that it fails.
<div class="row col-md-12">
<?php
// check if the repeater field has rows of data
if( have_rows('pics') ):
// loop through the rows of data
while ( have_rows('pics') ) : the_row();
// display a sub field value
?><div class="col-md-4">
<?php
$image = get_field('img');
if( !empty($image) ): ?>
<img src="<?php echo $image; ?>" alt="<?php echo $image['alt']; ?>" />
<?php endif; ?>
</div> <?
endwhile;
else :
// no rows found
endif;
?>
</div>
What is causing the image data to not loop?
Your code looks ok, but having checked how I did it I believe you should be using
get_sub_field
instead ofget_field
http://www.advancedcustomfields.com/resources/get_sub_field/
Your comment about using the [‘url’] part of the array is also relevant. This is working for me;
I think this is what you have to do:
This is assuming that you are outputting an image object and not a url in your ACF settings.