Google – Fonts über das Divi Text-Modul hochladen

Wenn man Fonts im woff oder woff2 format hochladen möchte, bekommt man eine Fehlermeldung, dass man dazu keine Berechtigung hat.

Mit etwas Code, welchen man in die function.php des Child_Themes einfügt kann man es aber problemlos erledigen.

Hier gibt es eine umfangreiche Anleitung auf You-Tube.

add_filter( 'wp_check_filetype_and_ext', 'my_file_and_ext_woff', 10, 4 );
function my_file_and_ext_woff( $types, $file, $filename, $mimes ) {
    if ( false !== strpos( $filename, '.woff' ) ) {
        $types['ext']  = 'woff';
        $types['type'] = 'font/woff|application/font-woff|application/x-font-woff|application/octet-stream';
    }
    if ( false !== strpos( $filename, '.woff2' ) ) {
        $types['ext']  = 'woff2';
        $types['type'] = 'font/woff2|application/octet-stream|font/x-woff2';
    }

    return $types;
}

/* Mime Types Support */
add_filter('upload_mimes', 'custom_mime_types', 999999);

function custom_mime_types($mimes) {
  $mimes['woff'] = 'application/font-woff';
  $mimes['woff2'] = 'application/font-woff2';
  return $mimes;
}

/* Custom Font Types Support */
add_filter('et_pb_supported_font_formats', 'custom_font_formats', 1);
function custom_font_formats() { 
return array('woff', 'woff2');
}
DSGVO Cookie Consent mit Real Cookie Banner