Support

Account

Home Forums General Issues Get ALT tag for image inside repeater Reply To: Get ALT tag for image inside repeater

  • I think I figured it out. I was using ‘Image URL’ and needed to switch to ‘Image Array’ and change the code to the following. If someone could confirm I’m doing this correctly that would be great.

    <?php while(the_repeater_field('banner')): ?>
    <?php $image = get_sub_field('image'); ?>
    <div>
        <h1><?php the_sub_field('heading'); ?></h1>
        <p><?php the_sub_field('description'); ?></p>
        <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>">
    </div>
    <?php endwhile; ?>