1 vote

Enable font mimetypes for upload

PBF has a custom typography option that allows you to upload a font file…except font files aren’t default-allowed on WP, and the function.php for this theme doesn’t have the code to enable font mimetypes. That means I either need to make a child theme, or I need to go install a custom typography plugin…which seems like it should be unnecessary what with custom typography being a built-in feature of this theme.
Completed Mackenzie Morgan shared this idea

3 Comments

  • Hi,

    what mime-types are you missing?

    With the Premium Add-On installed we add the following mime-types to the upload-mimes:

    /**
     * Allow font uploads.
     *
     * @param array $mime_types The mime types.
     *
     * @return array The updated mime types.
     */
    function wpbf_add_custom_upload_mimes( $mime_types ) {
    
    	$mime_types['otf']   = 'application/x-font-otf';
    	$mime_types['woff']  = 'application/x-font-woff';
    	$mime_types['woff2'] = 'application/x-font-woff2';
    	$mime_types['ttf']   = 'application/x-font-ttf';
    	$mime_types['svg']   = 'image/svg+xml';
    	$mime_types['eot']   = 'application/vnd.ms-fontobject';
    
    	return $mime_types;
    
    }
    add_filter( 'upload_mimes', 'wpbf_add_custom_upload_mimes', 0 );
    Reply
  • I was trying to upload a TTF, and it wasn’t allowing it. Interesting. Maybe it’s a bug?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

We take your privacy seriously! See our Privacy Policy.

3 Comments

  • Hi,

    what mime-types are you missing?

    With the Premium Add-On installed we add the following mime-types to the upload-mimes:

    /**
     * Allow font uploads.
     *
     * @param array $mime_types The mime types.
     *
     * @return array The updated mime types.
     */
    function wpbf_add_custom_upload_mimes( $mime_types ) {
    
    	$mime_types['otf']   = 'application/x-font-otf';
    	$mime_types['woff']  = 'application/x-font-woff';
    	$mime_types['woff2'] = 'application/x-font-woff2';
    	$mime_types['ttf']   = 'application/x-font-ttf';
    	$mime_types['svg']   = 'image/svg+xml';
    	$mime_types['eot']   = 'application/vnd.ms-fontobject';
    
    	return $mime_types;
    
    }
    add_filter( 'upload_mimes', 'wpbf_add_custom_upload_mimes', 0 );
  • I was trying to upload a TTF, and it wasn’t allowing it. Interesting. Maybe it’s a bug?

Comments are closed.

Scroll to Top

Download

Download Page Builder Framework and be the first to get informed about new features & updates!

OR

Get 10% off our Premium Add-On (yearly plan).
Coupon Code to enter during checkout: 10OFF View Pricing