OTF font not extended in Wordpress

I want to upload custom fonts to my WordPress dashboard. When I try to load the font file, it shows an error:

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

      

Then I resolved the font to all files using the following code:

  add_filter('upload_mimes', 'add_custom_upload_mimes');
  function add_custom_upload_mimes($existing_mimes) {
    $existing_mimes['otf'] = 'application/x-font-opentype';
    $existing_mimes['woff'] = 'application/x-font-woff';
    $existing_mimes['ttf'] = 'application/x-font-ttf';
    $existing_mimes['svg'] = 'image/svg+xml';
    $existing_mimes['eot'] = 'application/vnd.ms-fontobject';
    return $existing_mimes;
  }

      

Now all font types are loaded, but when I load the .otf font it shows me the same error.

Please help me to solve this problem. Thanks in advance.

+3


source to share


3 answers


The blow is a step towards solving this problem.

Open the wp-config.php file of your WordPress installation and above the line where it says / * That's it, stop editing! Enjoy blogging. * / add the following code anywhere:



define('ALLOW_UNFILTERED_UPLOADS', true);

      

link: https://tribulant.com/blog/wordpress/how-to-fix-sorry-this-file-type-is-not-permitted-for-security-reasons/

0


source


try using

$existing_mimes['otf'] = 'font/otf';

      



or

$existing_mimes['otf'] = 'application/font-sfnt';

      

+2


source


It's been a long time since you made this post. But I am using a plugin called "WP Add Mime Types".

And as a value in the plugin settings (Settings -> Myme type settings) I added this: otf = application / x-font-opentype

This works for me :)

+1


source







All Articles