Support

Account

Home Forums Add-ons Repeater Field How to get alt tags using repeater with Image ID?

Unread

How to get alt tags using repeater with Image ID?

  • I have the following code for calling the images in the slider but no idea on how to get the alt tag. I tried varied methods but I could be missing something. Please help.

    <div id="gallery_01" class="bxslider" style=""> 
    <div><a href="#" class="elevatezoom-gallery active" data-update="" data-image="<?php echo $feat_image ?>" data-zoom-image="<?php echo $feat_image ?>"><img src="<?php echo $feat_image ?>" alt="<?php echo $alt; ?>" /></a></div>
    <?php
    // check if the repeater field has rows of data
    if( get_field('trailerimages') ):
    // loop through the rows of data
    foreach ( get_field('trailerimages') as $image ): ?>
    <div><a href="#" class="elevatezoom-gallery" data-update="" data-image="<?php echo $image['image']['url']; ?>" data-zoom-image="<?php echo $image['image']['url']; ?>"><img src="<?php echo $image['image']['url']; ?>" width="90" alt="<?php echo $alt; ?>" /></a></div>
    <?php endforeach;
    endif;
    ?>
    </div><!-- End of gallery_01 -->

    The variables that I have got defined above this code is as follows:

    $thumb_id = get_post_thumbnail_id();
    $thumb_url_array = wp_get_attachment_image_src($thumb_id, 'large', true);
    $feat_image = $thumb_url_array[0];
    							
    $feat_imageid = get_sub_field('image');
    $feat_image_info = get_post( $thumb_id );
    $alt = get_post_meta($feat_image_info->ID,'_wp_attachment_image_alt',true);

    This code combinations shows me the alt tag for the first image i.e. feat_image only and not for all the images that are set in the repeater field.

    By the way, the repeater field is ‘trailerimages’ and the sub_field is ‘image’

    Please help.

Viewing 1 post (of 1 total)

The topic ‘How to get alt tags using repeater with Image ID?’ is closed to new replies.