For added security, WordPress allows you to upload only the most commonly used file types. You can upload commonly used image, audio/video and document formats using the default media uploader. But what if you wanted to upload a file type that is not allowed? In this article, we will show you how to add additional file types to upload to WordPress.
If you don't like the video or need more instructions, continue reading.
WordPress allows you to upload the most common image, audio/video, PDF, Microsoft Office and OpenOffice files. The WordPress codex has a full list of allowed file types and extensions.
Security is the main reason behind limiting the types of files that users can upload. However, this does not mean that users cannot change this. Using a little bit of code, you can add a new file type and extension to WordPress.
For example, add this code to your theme's functions.php file or a site-specific plugin to allow the SVG file type to load:
function my_myme_types ($ mime_types) $ mime_types ['svg'] = 'image / svg + xml'; // Añadiendo la extensión svg return $ mime_types; add_filter ('upload_mimes', 'my_myme_types', 1, 1);
Notice that the file extension goes as the key in the associated $mime_types 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 . You can find mime types of several common file extensions on this page.
You can also add multiple file types in one code snippet, like this:
function my_myme_types ($ mime_types) $ mime_types ['svg'] = 'image / svg + xml'; // Agregar la extensión svg $ mime_types ['psd'] = 'image / vnd.adobe.photoshop'; // La adición de archivos de photoshop devuelve $ mime_types; add_filter ('upload_mimes', 'my_myme_types', 1, 1);
We hope this article helped you learn how to allow additional file types to be uploaded in WordPress. You may also want to take a look at how to increase the maximum file upload size in WordPress.
If you enjoyed this article, please subscribe to our WordPress YouTube Channel video tutorials. You can also find us on Twitter and Google.+.