Check filename ending & a fileuploader
<?php
$filetype = wp_check_filetype('image.jpg');
echo $filetype['ext']; // will output jpg
?>
To use with ACF
if ( have_rows( 'file_uploader' ) ):
echo '<section class="section col-1 no-full-width inner-grid" style="flex-direction: column;">';
echo '<p style="padding-bottom: 20px;"><strong>Vedlagte filer<span class="dashicons dashicons-download"></span></strong></p>';
echo '<div class="download-file-container">';
while ( have_rows( 'file_uploader' ) ) : the_row();
$file = get_sub_field( 'upload_file' );
if ( $file ):
$filetype = wp_check_filetype( $file['filename'] );
$icon = $file['icon'];
if ( $file['type'] == 'image' ) {
$icon = $file['sizes']['thumbnail'];
}
?>
<div class="rc-Employee_Contact" style="align-self: flex-start; padding-bottom: 40px;">
<div class="img-container">
<img src="<?php echo $icon; ?>" alt="icon">
</div>
<a href="<?php echo $file['url']; ?>"><span>Last ned <?php echo $filetype['ext']; ?></span></a>
</div>
<?php endif;
endwhile;
else :
// no rows found
echo '</div>';
echo '</section>';
endif; ?>