0Day Forums
How do I allow a single Wordpress site to accept my .ttf file upload? - Printable Version

+- 0Day Forums (https://0day.red)
+-- Forum: Coding (https://0day.red/Forum-Coding)
+--- Forum: CMS (https://0day.red/Forum-CMS)
+---- Forum: WordPress (https://0day.red/Forum-WordPress)
+---- Thread: How do I allow a single Wordpress site to accept my .ttf file upload? (/Thread-How-do-I-allow-a-single-Wordpress-site-to-accept-my-ttf-file-upload)



How do I allow a single Wordpress site to accept my .ttf file upload? - stassfurtite427122 - 07-27-2023

I'm using the Font Organizer plugin for Wordpress. It has a nice option to upload a font, which I have saved to my computer. I just need to somehow get Wordpress to accept it so I can use it here:

[![enter image description here][1]][1]

However, I'm getting an error: `Error uploading the file: Sorry, this file type is not permitted for security reasons.`

How do I let Wordpress temporarily allow this? Also, is this method even going to work out? The end goal is for it to show up on the drop down list in the image above because I need to change the font of the header text. I can do any programming stuff needed.


[1]:



RE: How do I allow a single Wordpress site to accept my .ttf file upload? - budidpwmhbdqfi - 07-27-2023

There is [plugins][1] that allow you to whitelist certain mime types.

Also the `add_filter` hook can be used to extend the default allowed mime types from a theme or plugin.


*P.S.: You really shouldn't use ttf for web use, since it's uncompressed. Use woff, woff2 or eot instead.*


[1]:

[To see links please register here]




RE: How do I allow a single Wordpress site to accept my .ttf file upload? - overclassifies879209 - 07-27-2023

You can allow uploading the .ttf font on your site, by adding a simple filter code on function.php file.

Below is the code for .ttf font only

add_filter('upload_mimes', 'add_custom_upload_mimes');
function add_custom_upload_mimes($existing_mimes) {
$existing_mimes['ttf'] = 'application/x-font-ttf';
return $existing_mimes;
}



You can add more MIME type in the function to allow to upload those file.


RE: How do I allow a single Wordpress site to accept my .ttf file upload? - natividadnativism237 - 07-27-2023

Unfortunately for me neither the code snippet for **functions.php** or the plugin worked.

I had to temporarily add the following code to **wp-config.php**:

define('ALLOW_UNFILTERED_UPLOADS', true);

And then of course deleted it as soon as I had uploaded the font.

(However in future I will attempt to use compressed font versions as suggested in the bottom two answers).


RE: How do I allow a single Wordpress site to accept my .ttf file upload? - truehearted403 - 07-27-2023

You can use a code snippet to add support for certain mime types, or use a plugin to enable that feature. Or you could avoid the issue at all by converting the file to a compressed version, for example using an online converter like

[To see links please register here]


This was the first one I run into while trying to solve your very same problem; it's not the best or the fastest or anything: it just works.