By default, WordPress doesn’t support uploading of AVIF images to the media library. Luckily this is super easy to fix with a minor addition to your theme’s functions.php
file and a helpful plugin.
The Solution
- Add the following PHP code to your theme’s
functions.php
file:
function cmyee_allowed_mime_types( $mime_types ) {
//AVIF Images
$mime_types['avif'] = 'image/avif';
return $mime_types;
}
add_filter( 'upload_mimes', 'cmyee_allowed_mime_types', 1, 1 );
2. Download & activate the Lord of the Files: Enhanced Upload Security plugin.
3. That’s it! Now you can upload AVIF images in the WordPress media library.
Hi Chris,
I’m trying to follow your steps… But it doesn’t work to me.
Hi Pau,
Not sure what your issue could be, it works perfectly on my localhost version of WordPress, here are some suggestions:
If you have multiple themes, make sure you edit your active theme’s functions.php file.
Cheers.