apply_filters( 'upload_mimes', array $t, int|WP_User|null $user )

Filters list of allowed mime types and file extensions.

Parameters Parameters


(array) Mime types keyed by the file extension regex corresponding to those types.


(int|WP_User|null) User ID, User object or null if not provided (indicates current user).

Top ↑

Source Source

File: wp-includes/functions.php

View on Trac

Top ↑

Changelog Changelog

Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Jb Audras

    (example taken from @dotmastaz’s feedback)
    Allow SVGZ mime type:

    function svgz_mime_types( $mimes ) {
            // SVGZ allowed mime types.
            $mimes['svgz'] = 'application/x-gzip';
            return $mimes;
    add_filter( 'upload_mimes', 'svgz_mime_types' );

    And if you want to know what is your real file mime type, you can use this service:

  2. Skip to note 2 content
    Contributed by Mahesh Waghmare

    Add MIME types.

    function my_custom_mime_types( $mimes ) {
    	// New allowed mime types.
    	$mimes['svg']  = 'image/svg+xml';
    	$mimes['svgz'] = 'image/svg+xml';
    	$mimes['doc']  = 'application/msword'; 
        // Optional. Remove a mime type.
        unset( $mimes['exe'] );
    	return $mimes;
    add_filter( 'upload_mimes', 'my_custom_mime_types' );

You must log in before being able to contribute a note or feedback.