Search code examples
wordpressfontswordpress-themingmime-types

OTF font not uploded in Wordpress


I want to upload the custom fonts in WordPress dashboard. When I try to upload the font file, it is showing the error:

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

Then I have allowed the font all files by using below 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 type of font get uploaded but when I upload the .otf font it is showing me the same error.

Please help me to resolve this issue. Thanks In Advance.


Solution

  • Blow is the step to resolved this issue.

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

    define('ALLOW_UNFILTERED_UPLOADS', true);
    

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