jenhuls
1/17/2016 - 4:49 AM

WordPress: Advanced Custom Fields Pro repeater field image/file upload information plus file size and file extension. Make sure your field

WordPress: Advanced Custom Fields Pro repeater field image/file upload information plus file size and file extension.

Make sure your field in the repeater is set to "File ID" and not "File URL." This allows looping through the file information.

<?php if( have_rows('repeater_field') ): ?>
  <ul>
<?php while( have_rows('repeater_field') ): the_row(); 
  $attachment_id = get_sub_field('repeater_sub_field');
  // (thumbnail, medium, large, full or custom size)
  $size = "thumbnail";
  // Attachment URL
   $url = wp_get_attachment_url( $attachment_id );
   // Get the file name
   $title = get_the_title( $attachment_id );
   //file extension
   $path_info = pathinfo( get_attached_file( $attachment_id ) );
  // filesize
  $filesize = filesize( get_attached_file( $attachment_id ) );
  $filesize = size_format($filesize, 2);
?>			
  	<li filetype-<?php echo $path_info['extension']; ?>"><a class="image-anchor" href="<?php echo $url; ?>"><i class="fa fa-file-text-o"></i> <span class="file-name"> <?php echo $title; ?>.<?php echo $path_info['extension']; ?></span> <span class="file-size"><?php echo $filesize; ?></span></a></li>
    <?php endwhile; ?>
  </ul>
<?php endif; ?>