Site logo

[Resolved] Local Font Use Of OTF File

Home Forums Support [Resolved] Local Font Use Of OTF File

Home Forums Support Local Font Use Of OTF File

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #2189160
    Michelle

    I am trying to upload a local font into my Media Library use via Code Snippets, and get a message saying “this file type is not allowed”. Is there a php snippet that would allow me to upload an .otf? Converting my font to a .ttf may be more difficult since it is a custom ancient font I made.

    Here is the code I am using, which is clearly for a .ttf

    add_filter( ‘upload_mimes’, function( $mimes ) {
    $mimes[‘woff’] = ‘application/x-font-woff’;
    $mimes[‘woff2’] = ‘application/x-font-woff2’;
    $mimes[‘ttf’] = ‘application/x-font-ttf’;
    $mimes[‘svg’] = ‘image/svg+xml’;
    $mimes[‘eot’] = ‘application/vnd.ms-fontobject’;

    return $mimes;
    } );

    I tried to make it work by adding this line after the ‘ttf’ line, but it did not work:

    $mimes[‘otf’] = ‘application/x-font-otf’;

    #2189182
    Ying
    Staff
    Customer Support

    Hi Michelle,

    Can you give this line a try ? $mimes['otf'] = 'font/otf';

    #2189184
    Michelle

    Sure. I just added this to my wp-config:

    define(‘ALLOW_UNFILTERED_UPLOADS’, true);

    It still didn’t work. I will give your code a try now.

    #2189186
    Michelle

    It still won’t allow me to upload the file. It is a working font file. I have it installed in WORD

    #2189202
    Ying
    Staff
    Customer Support

    You can also try these 2 lines:
    $existing_mimes['otf'] = 'application/font-sfnt';

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

    But adding define('ALLOW_UNFILTERED_UPLOADS', true); to wp-config.php should work.

    If it still doesn’t work, it’s better reach out to WP’s support as theme doesn’t have the control over this.

    #2189205
    Michelle

    I was able to get the fonts uploaded by modifying my wp-config. Thank you.

    #2190059
    Ying
    Staff
    Customer Support

    No problem 🙂

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.