Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save pigmentGit/faeb26ba0da5a94c324b to your computer and use it in GitHub Desktop.

Select an option

Save pigmentGit/faeb26ba0da5a94c324b to your computer and use it in GitHub Desktop.

Revisions

  1. pigmentGit created this gist Oct 21, 2014.
    16 changes: 16 additions & 0 deletions Get alt-text on image with acf-repeater field
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    <?php
    if( have_rows('acf_repeaterfield') ):
    while ( have_rows('acf_repeaterfield') ) : the_row();
    $imageID = get_sub_field('acf_subfield');
    $image = wp_get_attachment_image_src( $imageID, 'full' );
    $alt_text = get_post_meta($imageID , '_wp_attachment_image_alt', true);
    ?>

    <img src="<?php echo $image[0]; ?>" alt="<?php echo $alt_text; ?>" class="port-img front" />

    <?php
    endwhile;
    else :
    // none
    endif;
    ?>