How can we get Wordpress to support .jfif image upload?

Viewed 3235

We and our users cannot upload images with .jfif extension (e.g. whatsapp images) to our website. We have tried to edit the functions.php to support .jfif but I didn't work. Same problem holds for our native IOS and Android apps which are integrated to our wordpress.

2 Answers

You need to add this to your functions.php

Since JFIF is just another file extension for JPG, and this mime type exists. You need to add the file extension to the accepted array.

See: https://developer.wordpress.org/reference/hooks/mime_types/

<?php

add_filter('mime_types', 'dd_add_jfif_files');
function dd_add_jfif_files($mimes){
    $mimes['jfif'] = "image/jpeg";
    return $mimes;
}

Add this code your active theme functions.php file. Filters list of allowed mime-types(jfif) and file extensions.Wordpress Media can accept .jfif extension file.

See:https://developer.wordpress.org/reference/hooks/upload_mimes/

<?php
add_filter( 'upload_mimes', 'custom_mime_types', 1, 1 );
function custom_mime_types( $mime_types ) {
$mime_types['jfif'] = 'image/jfif+xml'; // Adding .jfif extension

return $mime_types;
}
?>
Related