For some security reasons, WordPress only allows uploading some particular file formats of files. The commonly allowed formats are image files, audio files, video files, PDF, Microsoft Office or OpenOffice documents, etc… Any other types of files will be blocked if you try to upload them to the media library. Though, you can’t upload any other formats of files to use on your website. You don’t like limitations, and we also don’t. So, we prepared this article on How to add additional file types to be uploaded to WordPress. In this article, we are sharing the method to get any of the file types you like on your website. So, let’s give a look.
Which file types are allowed by WordPress by default?
WordPress limited the allowed file types to a few numbers. You can upload image files, audio files, video files, PDF, Microsoft Office or OpenOffice documents, etc… to WordPress. You will be blocked from uploading other types of files to your WordPress. Below is a screenshot of an error message, while trying to upload an unsupported file type.
As you can see, it displays an error that says – Sorry, this file type is not permitted for security reasons.
These are the file types that are supported by WordPress –
Type | Extensions |
---|---|
Image | .jpg, .jpeg, .png, .gif, .ico |
Video | .mp4, .m4v, .avi, .mov, .wmv, .mpg, .ogv, .3gp, .3g2 |
Audio | .mp3, .m4a, .ogg, .wav |
Document | .pdf, .doc, .docx, .xls, .xlsx, .ppt, .pptx, .pps, .ppsx, .odt |
Find the full list of allowed file types on WordPress from the WordPress docs.
File types that are not allowed on WordPress
There are many file types that are not allowed by default on WordPress. If you want to use those file types, you will have to manually enable them one by one based on your requirements. One of the most common file types that users always try to add is SVG. These are other common file types that are not allowed –
Type | Extensions |
---|---|
Image | .svg, .bmp |
Video | .flv |
Documents | .css, .js, .json |
Before enabling any file type
Before enabling any additional file types into WordPress, there is one important thing that you should always keep in mind. For every single additional file type you keep adding, you expose your website to be vulnerable to the security threats related to that certain file type.
For example, SVG is known to come with certain threats, which is the reason why WordPress doesn’t allow it by default. So while enabling any additional file types, it is always a good idea to use a dedicated plugin that does some security measures. In the case of SVG, you can use the SVG Support plugin that does the necessary security filters for you.
How to Add Additional File Types to be Uploaded to WordPress
WordPress is an entirely customizable platform. Custom codes can always help you to fulfill your needs. WordPress blocked certain file types due to security reasons. It doesn’t mean, you can’t upload other formats. You can simply edit some codes and easily access the permission to add new file types that can be uploaded to the WordPress website.
Method 1. Using custom filters
Use the following code in your functions.php file to add an exception to the .svg files.
function my_myme_types ($mime_types) {
$mime_types['svg'] = 'image/svg+xml'; //Adding svg extension
return $mime_types;
}
add_filter('upload_mimes', 'my_myme_types', 1, 1);
The ‘svg’ part will be replaced by the extension of the file you want to add. The file extension is the key in $mime_types associated array, and the mime type goes as its value. SVG file extension represents files with the mime type image/svg+xml in this example. Find out more about mime types and use the appropriate one’s in the correct place.
If you want to add multiple extensions at the same time, use the code given below.
function my_myme_types ($mime_types) {
$mime_types['svg'] = 'image/svg+xml'; //Adding svg extension
$mime_types['psd'] = 'image/vnd.adobe.photoshop'; //Adding photoshop files
return $mime_types;
}
add_filter('upload_mimes', 'my_myme_types', 1, 1);
Now, you will be able to upload the specified file formats without any restrictions or blocks.
Method 2. Using plugins
There are certain plugins that allow you to enable custom formats to be uploaded to WordPress. One such plugin is WP Extra File Types. There is also another plugin File Upload Types that can be used for the same purpose.
Which plugin You should use will completely depend on your requirements and the features they provide. Before starting to use any plugin, make sure that they meet your certain requirements and doesn’t charge you more than what you can afford. It is always a good idea to go with a free plugin instead of paying for a premium one for such a small functionality.