Modify Allowed Upload Mime Types

This snippet let’s you add or remove allowed file types in the WordPress upload popup. Adding font files like .woff are not allowed by default and this fixes that.

Code Snippet:

function edit_upload_types($existing_mimes = array()) {
    // allow .woff
    $existing_mimes['woff'] = 'font/woff';

    // add as many as you want with the same syntax

    // disallow .jpg files
    unset( $existing_mimes['jpg'] );

    return $existing_mimes;
}
add_filter('upload_mimes', 'edit_upload_types');

Posted in Admin area