Just wondering why you guys never follow up on your blogposts ad or video tutorials.
When you don’t want to just turn of the option to reply.
This is becoming an embarrassment and not just on your own site but also on Youtube and the Facebook groups!
]]>Hi I tried the above function and now it won’t let me upload png or jpg files. I tried to add those in the function but it doesn’t work. Is there a way to get them allow uploads? I can successfully upload svg using a different function and it allows png and jpg uploads but not font files.
Thanks
Hello Connie!
Robey from the Divi Engine team here.
WordPress is notoriously fussy when it comes to fonts, especially TTF files.
Sometimes for cases like this, you need to add an additional filter to the functions.php file below the code block where we enable the mime types.
Please go ahead and add the code below to your functions.php and let me know if it works 🙂
function divi_engine_font_correct_filetypes( $data, $file, $filename, $mimes, $real_mime ) {
if ( ! empty( $data['ext'] ) && ! empty( $data['type'] ) ) {
return $data;
}
$wp_file_type = wp_check_filetype( $filename, $mimes );
// Check for the file type you want to enable, e.g. 'svg'.
if ( 'ttf' === $wp_file_type['ext'] ) {
$data['ext'] = 'ttf';
$data['type'] = 'font/ttf';
}
if ( 'otf' === $wp_file_type['ext'] ) {
$data['ext'] = 'otf';
$data['type'] = 'font/otf';
}
return $data;
}
add_filter( 'wp_check_filetype_and_ext', 'divi_engine_font_correct_filetypes', 10, 5 );
I used the mime types ‘font/otf’ and ‘font/ttf’
no chance
]]>