ACF Repeater with Image Object starter code to get movin quick

Some code to get started with a repeater that has an Image ACF that pulls the image object.

<?php if( have_rows('repeater_field_name') ): ?>
	<?php while ( have_rows('repeater_field_name') ) : ?>
	<?php the_row(); ?>
 
	 <?php 
        // Get field Name
        $image = get_sub_field('picture'); 
        $url = $image['url'];
        $title = $image['title'];
        $alt = $image['alt'];
        $caption = $image['caption'];
     
        // size or custom size that will go
        // into the "thumb" variable.
        $size = 'large';
        $thumb = $image['sizes'][ $size ];
        $width = $image['sizes'][ $size . '-width' ];
        $height = $image['sizes'][ $size . '-height' ];
        ?>
        
        <img src="<?php echo $thumb; ?>" alt="<?php echo $alt; ?>" title="<?php echo $title; ?>" />
        
       	<?php  the_sub_field('sub_field_name'); ?>
       
   <?php endwhile; ?>
<?php endif; ?>

 

Leave a Reply

Your email address will not be published. Required fields are marked *

46 − 44 =