Support

Account

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>&nbsp;<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; ?>