Want to upload more file types to your WordPress media library?
You must have noticed that WordPress doesn’t let you upload all file types via media uploader due to security reasons. You can only upload certain files, like images (.jpg, .png and .gif), documents (.doc, .xls, .ppt, .pdf), audio files (.wav, .mp3, .mp4) and videos (.mpg, .mov, .wmv).
But at times you might want to upload more file types to your WordPress site, like .bmp images, .psd, .ai, .page documents, etc.
Let’s check out how to securely upload additional file types to your WordPress media library.
How to Enable Additional File Upload Support in WordPress
You can extend your WordPress media library support for more file extensions in 2 ways.
- Method 1: Upload Additional File Type With a Plugin
- Method 2: Upload Additional File Type Without a Plugin
Method 1: Upload Additional File Type With a Plugin
To accept more file types in WordPress, you’ll need to install this plugin created by WPForms called File Upload Types.
It lets you accept files like .ai, .zip, .xml, .svg, .csv, .mobi, .cad, .dwg, and .dxf. You can accept any other file extensions that exist, including custom file types.
To get started, inside your WordPress admin, in the Plugins » Add New tab, search for the free File Upload Types plugin and install and activate it on your site.
With this plugin, it’s easy for you to extend your website’s support for more file types.
The plugin works by letting you adjust the internal file whitelist. You can manually control which types of file extensions your site can upload.
Configuring the File Upload Types Plugin
Once the plugin is installed and activated on your WordPress website, go to Settings » File Upload Types. You’ll see a list that shows you different file formats.
To extend the support for more file types, you can select the right file extensions in the list.
If you don’t see the file extension that you want to upload, scroll down until you find Add Custom File Types. Then add the details in there.
If you want to extend the support for more than one file type, use the ‘+’ symbol next to the Extension field. Once done click on the Save Settings button at the bottom of the screen. You should now be able to upload your desired file format easily.
Method 2: Upload Additional File Type Without a Plugin
If you don’t want to install a plugin to upload additional file types, simply add this code snippet to your functions.php file or your site-specific plugin.
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);
In the above code, you’ll notice that the file extension goes as the key in $mime_types associated array and the mime type goes as its value. In this example, the svg file extension represents files with the mime type image/svg+xml.
If you want to add multiple file types you can do that by using this:
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);
Once done, don’t forget to save your settings.
We hope this post helped you upload additional file types to your WordPress media library. You might also want to read about the best file upload plugins for WordPress.
We also have an easy tutorial on How to Create a File Upload Form in WordPress that you’ll find helpful.
Parse error: syntax error, unexpected ‘$mime_types’ (T_VARIABLE)