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’;