Site logo

Archived topic

Uploading ttf-files

3 replies · Started by Erika on December 1, 2022

Viewing posts 1–4 of 4

Hi there,

I use this script to allow the upload of font-files:
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;
} );

However, ttf-files are forbidden when I try to upload. I can´t see what´s wrong, can you help?

Thank you, Erika

Hi there,

that would mean either a security plugin or security mod on your server is stopping those from being uploaded.
If you use no security plugin then you would need to check with your host.

Alternatively, unless you need very specific TTF styling options you may want to consider just loading .woff and .woff2 fonts as they are supported across all modern browsers.

And if you only have ttf fonts you can use a font convertor like the one at Font Squirrel to convert them

Sorry, I forgot to close this ticket. Basically another option was to allow the upload of all file-types for a short time and that works in any case.

Glad to hear that!

This archived topic is closed to new replies.