Title: upload_mimes
Published: April 25, 2014
Last modified: February 24, 2026

---

# apply_filters( ‘upload_mimes’, array $t, int|WP_User|null $user )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/upload_mimes/?authuser=0&output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/upload_mimes/?authuser=0&output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/upload_mimes/?authuser=0&output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/upload_mimes/?authuser=0&output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/upload_mimes/?authuser=0&output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/hooks/upload_mimes/?authuser=0&output_format=md#wp--skip-link--target)

Filters the list of allowed mime types and file extensions.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/upload_mimes/?authuser=0&output_format=md#parameters)󠁿

 `$t`array

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

`$user`int|[WP_User](https://developer.wordpress.org/reference/classes/wp_user/)
|null

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

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/upload_mimes/?authuser=0&output_format=md#source)󠁿

    ```php
    return apply_filters( 'upload_mimes', $t, $user );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/functions.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/functions.php#L3668)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/functions.php#L3668-L3668)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/upload_mimes/?authuser=0&output_format=md#related)󠁿

| Used by | Description | 
| [get_allowed_mime_types()](https://developer.wordpress.org/reference/functions/get_allowed_mime_types/)`wp-includes/functions.php` |

Retrieves the list of allowed mime types and file extensions.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/upload_mimes/?authuser=0&output_format=md#changelog)󠁿

| Version | Description | 
| [2.0.0](https://developer.wordpress.org/reference/since/2.0.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/upload_mimes/?authuser=0&output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 7 content](https://developer.wordpress.org/reference/hooks/upload_mimes/?authuser=0&output_format=md#comment-content-2399)
 2.    [Mahesh Waghmare](https://profiles.wordpress.org/mahesh901122/)  [  9 years ago  ](https://developer.wordpress.org/reference/hooks/upload_mimes/#comment-2399)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupload_mimes%2F%23comment-2399)
     Vote results for this note: 3[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupload_mimes%2F%23comment-2399)
 4.  Add MIME types.
 5.      ```php
         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' );
         ```
     
 6.   * Allow SVGZ mime type:
      *     ```php
             &lt;?php function svgz_mime_types( $mimes ) {         // SVGZ allowed mime types.         $mimes['svgz'] = 'application/x-gzip';         return $mimes; } add_filter( 'upload_mimes', 'svgz_mime_types' ); ?&gt; 
            ```
        
      *  And if you want to know what is your real file mime type, you can use this
        service: [https://wp-check-mime-type.com/](https://wp-check-mime-type.com/).
      * [dotMastaz](https://profiles.wordpress.org/dotmastaz/) [6 years ago](https://developer.wordpress.org/reference/hooks/upload_mimes/#comment-3540)
 7.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupload_mimes%2F%3Freplytocom%3D2399%23feedback-editor-2399)
 8.   [Skip to note 8 content](https://developer.wordpress.org/reference/hooks/upload_mimes/?authuser=0&output_format=md#comment-content-3543)
 9.    [Jb Audras](https://profiles.wordpress.org/audrasjb/)  [  6 years ago  ](https://developer.wordpress.org/reference/hooks/upload_mimes/#comment-3543)
 10. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupload_mimes%2F%23comment-3543)
     Vote results for this note: 3[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupload_mimes%2F%23comment-3543)
 11. (example taken from @dotmastaz’s feedback)
      Allow SVGZ mime type:
 12.     ```php
         <?php
         function svgz_mime_types( $mimes ) {
                 // SVGZ allowed mime types.
                 $mimes['svgz'] = 'application/x-gzip';
                 return $mimes;
         }
         add_filter( 'upload_mimes', 'svgz_mime_types' );
         ?>
         ```
     
 13. And if you want to know what is your real file mime type, you can use this service:
     [https://wp-check-mime-type.com/](https://wp-check-mime-type.com/).
 14.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupload_mimes%2F%3Freplytocom%3D3543%23feedback-editor-3543)
 15.  [Skip to note 9 content](https://developer.wordpress.org/reference/hooks/upload_mimes/?authuser=0&output_format=md#comment-content-4810)
 16.   [Justin Kopepasah](https://profiles.wordpress.org/kopepasah/)  [  5 years ago  ](https://developer.wordpress.org/reference/hooks/upload_mimes/#comment-4810)
 17. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupload_mimes%2F%23comment-4810)
     Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupload_mimes%2F%23comment-4810)
 18. Filter the upload mime types to allow JSON files.
 19.     ```php
         <?php
         /**
          * Allow JSON file uploads to WordPress media library.
          *
          * Filters the uploads mime types to allow JSON files.
          *
          * @param array $types Currently allowed types.
          *
          * @return array Filtered types.
          */
         add_filter(
         	'upload_mimes',
         	function( $types ) {
         		return array_merge( $types, array( 'json' => 'text/plain' ) );
         	}
         );
         ```
     
 20.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupload_mimes%2F%3Freplytocom%3D4810%23feedback-editor-4810)
 21.  [Skip to note 10 content](https://developer.wordpress.org/reference/hooks/upload_mimes/?authuser=0&output_format=md#comment-content-5417)
 22.   [Shoaib Ali](https://profiles.wordpress.org/shoaibkarimali/)  [  5 years ago  ](https://developer.wordpress.org/reference/hooks/upload_mimes/#comment-5417)
 23. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupload_mimes%2F%23comment-5417)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupload_mimes%2F%23comment-5417)
 24. Allow CSV file type.
 25.     ```php
         function extend_mime_types( $types ) {
         	$types['csv'] = 'text/csv';
         	return $types;
         }
         add_filter( 'upload_mimes', 'extend_mime_types' );
         ```
     
 26.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupload_mimes%2F%3Freplytocom%3D5417%23feedback-editor-5417)
 27.  [Skip to note 11 content](https://developer.wordpress.org/reference/hooks/upload_mimes/?authuser=0&output_format=md#comment-content-5621)
 28.   [thejaydip](https://profiles.wordpress.org/iamjaydip/)  [  4 years ago  ](https://developer.wordpress.org/reference/hooks/upload_mimes/#comment-5621)
 29. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupload_mimes%2F%23comment-5621)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupload_mimes%2F%23comment-5621)
 30. Allow uploading fonts files.
 31.     ```php
         function wpdocs_allow_mime_types( $mimes ) {
     
         		$mimes['ttf']   = 'font/ttf';
         		$mimes['woff']  = 'font/woff';
         		$mimes['woff2'] = 'font/woff2';
         	}
         	return $mimes;
         }
     
         add_filter( 'upload_mimes', 'wpdocs_allow_mime_types' );
         ```
     
 32.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupload_mimes%2F%3Freplytocom%3D5621%23feedback-editor-5621)
 33.  [Skip to note 12 content](https://developer.wordpress.org/reference/hooks/upload_mimes/?authuser=0&output_format=md#comment-content-6200)
 34.   [Мария Рангелова](https://profiles.wordpress.org/blaugrana/)  [  3 years ago  ](https://developer.wordpress.org/reference/hooks/upload_mimes/#comment-6200)
 35. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupload_mimes%2F%23comment-6200)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupload_mimes%2F%23comment-6200)
 36.     ```php
         // To upload photos in format WebP
     
         function wpdocs_custom_mime_types( $mimes ) {
     
         	// New allowed mime types.
         	$mimes['webp'] = 'image/webp';
     
         	return $mimes;
         }
     
         add_filter( 'upload_mimes', 'wpdocs_custom_mime_types' );
         ```
     
 37. If you work locally, for example on XAMPP, you should also include extension=gd
     in php.ini, just uncomment it, removing ; in front of it.
 38.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupload_mimes%2F%3Freplytocom%3D6200%23feedback-editor-6200)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupload_mimes%2F)
before being able to contribute a note or feedback.