Being able to manage all the files we upload in WordPress in one place (the media library) is something very useful. Some say the media library could be improved—some requested features are still missing, like file tagging, sorting by topic or by file extension, or searching for duplicates—, but its usefulness is clear when reusing or sharing files between our contents without having to upload them more than once.
Maybe you didn’t know that, but WordPress only allows file uploading into the media library if such files meet certain conditions. Specifically, you can only upload the following file types by default in a standard WordPress installation:
- Images
.jpg
.jpeg
.png
.gif
.ico
- Documents
.pdf
(Portable Document Format; Adobe Acrobat).doc
,.docx
(Microsoft Word Document).ppt
,.pptx
,.pps
,.ppsx
(Microsoft PowerPoint Presentation).odt
(OpenDocument Text Document).xls
,.xlsx
(Microsoft Excel Document).psd
(Adobe Photoshop Document)
- Audio
.mp3
.m4a
.ogg
.wav
- Video
.mp4
,.m4v
(MPEG-4).mov
(QuickTime).wmv
(Windows Media Video).avi
.mpg
.ogv
(Ogg).3gp
(3GPP).3g2
(3GPP2)
However, it’s not always possible to upload all these file types—some hosting providers limit the set of valid file types and even the maximum file size you can upload in your installation. If you have problems uploading some permitted file types, contact your provider first to get an explanation.

Recently we received a comment asking us how to expand the list by adding more file types. As surely there are more people interested in learning how to do this, in this post I explain the solution.
Modiying wp-config.php
If you do not want to limit the file types and thus upload any file into the media library, the easiest way to follow is to add the following line in the wp-config.php
file:
define( 'ALLOW_UNFILTERED_UPLOADS', true );
The wp-config.php
file allows us to modify the default behavior of WordPress. You’ll find it in the root of your server. Using the above statement we are allowing all administrators to upload any file type. Note that this can be dangerous if you do not trust too much your administrators and what they can do. Be careful when adding this statement or you might end up regretting your decision ?
Using the upload_mimes
filter
If you want to solve the problem of uploading additional file types to WordPress, but being selective and only allowing a controlled subset of file types, the best you can do is use the upload_mimes
filter. As always, you have all the information in the Codex.
This filter is super easy to use. You only need to add a piece of code similar to the following in the functions.php
file of your theme or inside a new plugin of your own:
You can ignore the first line (<?php
), which simply opens a block of PHP code. Line 2 indicates that the function my_mime_types
will be executed with the upload_mimes
filter. Lines 3 to 10 define this function. my_mime_types
has one single parameter ($mime_types
)—the list of allowed file types.
If you want to allow SVG and JSON files in the media library, just add lines 4 and 5, respectively. This is how it works: to add a new file type, you just have to create a new entry in the $mime_types
list with the file extension and mime type. To find the proper mime type of an extension go to the official list of media types that the IANA (Internet Assigned Numbers Authority) defines.
On the other hand, you can also disable certain file types. You can prohibit the file types you want by simply unset
ting their entries in the $mime_types
array, as I did in lines 7 and 8, where I disabled Microsoft Excel file uploading.

Nelio Content
I’m so happy about Nelio Content that I will sound like a payed advocate… but here’s why you’ll love it: it works as promised, its auto-scheduling feature is top-notch, Nelio’s value for money is unmatched, and the support team feels like your own.

Panozk
Summary
As you can see here, modifying the default behavior of WordPress to have greater control over the file types you allow in your installation is very simple. And best of all, you don’t need to install a complex plugin for this. With just a few lines of PHP code or even editing the wp-config.php
file you’ll get what you want.
Now it’s your turn. Explain us which file types you miss in WordPress and your experience using the solutions I have proposed in this article.
Featured image by Andrew Pons.
Leave a Reply