Home › Forums › General Issues › how to get filetype (extension)? › Reply To: how to get filetype (extension)?
great, thanks that works 🙂
<?php if(get_field("downloads")): ?> <div id="downloadbox"> <h3>Files</h3> <ul class="downloads"> <?php while(the_flexible_field("downloads")): ?> <?php if(get_row_layout() == 'flexible_download'): // layout: Content ?> <?php $attachment_id = get_sub_field('file'); $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); // part where to get the extension $path_info = pathinfo( get_attached_file( $attachment_id ) );?> <li class="cf dlbox"> <a href="<?php echo $url; ?>" class="cf"> <span class="dl-title"><?php echo $title; ?><small><nobr><strong>Size:</strong> <em>(<?php echo $filesize; ?>)</em></nobr></small></span> <span class="dl-extension"><span class="dl-extension-inner"><?php echo $path_info['extension']; ?></span></span> </a> </li> <?php endif; endwhile; ?> </ul> </div> <?php endif; ?>
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!
CPT registration is coming to ACF! We demoed the new feature during the most recent session of ACF Chat Fridays. Check out the summary for the details. https://t.co/k2KQ3WWBAz— Advanced Custom Fields (@wp_acf) March 7, 2023
© 2023 Advanced Custom Fields.