crazyyy
5/14/2014 - 3:00 PM

WordPress: ACF: get uploaded file size

WordPress: ACF: get uploaded file size

<?php
  $attachment_id = get_field('dl-fb2');
  $url = wp_get_attachment_url( $attachment_id );
  $title = get_the_title( $attachment_id );
  $myfile = filesize( get_attached_file( $attachment_id ) );
  $bytes = size_format($myfile, 2);
  if(get_field('dl-fb2')) { ?>
  
  <tr>
      <td><a href="<?php echo $url; ?>" title="<?php echo $title; ?>">Скачать в формате fb2</a></td>
      <td>Размер файла: <?php echo $bytes; ?></td>
  </tr>
  
<?php } ?>