Has anyone found a good way to upload AVIF images files through the WordPress media uploader?

I've seen variations of this code posted everywhere:

function allowed_mime_types( $mime_types ) {

  //AVIF Images
  $mime_types['avif'] = 'image/avif';

  return $mime_types;

add_filter( 'upload_mimes', 'allowed_mime_types' );

But, when I use that I still get an error:

Sorry, this file type is not permitted for security reasons.

I confirmed that avif is added to the list of extensions in the plupload localized script vars, but still no joy. What am I missing?

  • Try with adding this plugin for expand security reasons wordpress.org/plugins/blob-mimes
    – Gregory
    Dec 1 '20 at 0:58
  • Thanks for the suggestion. Can you confirm if that plugin allows AVIF uploads? What technique does it use? I took a quick look at the source, but it's a pretty heavy plugin, and I wasn't able to quickly see how it works.
    – Dominic P
    Dec 1 '20 at 19:17
  • honestly i've didn't try it, but after looking around, it seems to be the solution.
    – Gregory
    Dec 3 '20 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.