Home › Forums › General Issues › get filesize? › Reply To: get filesize?
finally got it:`
<?php $attachment_id = get_field('download');
$url = wp_get_attachment_url( $attachment_id );
$title = get_the_title( $attachment_id );
// part where to get the filesize
$filesize = filesize( get_attached_file( $attachment_id ) );
$filesize = size_format($filesize, 2);
// show custom field
if (get_field('download')): ?>
<a href=”<?php echo $url; ?>” ><?php echo $title; ?></a>
<!– show filesize –>
<?php echo $filesize; ?>
<?php endif; ?>
🙂 <- happy
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
Are you building WordPress sites with ACF and @BeaverBuilder, and wanted to use your ACF Blocks in both the block editor and Beaver Builder?— Advanced Custom Fields (@wp_acf) May 10, 2023
The BB team recently added support for using ACF Blocks in Beaver Builder. Check it out 👇https://t.co/UalEIa5aQi
© 2023 Advanced Custom Fields.