In this article, we’ll see about Manage File types in WordPress Media Library.
Table of Contents
The WordPress Media Library serves as a central hub for all your website’s media files, offering convenience and efficiency in managing your content.
However, sometimes you may encounter limitations in terms of allowed filetypes. Fear not!
We will explore effective techniques to manage file types in WordPress Media Library, empowering you with the flexibility to handle a wide range of media formats effortlessly.
Manage File types in WordPress Media Library
By default, WordPress restricts the types of files that can be uploaded to the Media Library. This is done for security reasons and to ensure optimal compatibility with various web browsers.
However, you may encounter scenarios where you need to include additional filetypes or exclude certain ones to accommodate your website’s unique requirements.
To Get allowed file types, add followings code in functions.php file:
function get_allowed_filetypes() { $allowed_filetypes = apply_filters( 'upload_mimes', array() ); return $allowed_filetypes; }
How to Add Allowed Filetypes to WordPress Media Library
By default, WordPress only allows you to upload certain file types.
Most common file types for images & Microsoft Office documents are allowed. But let’s take a look at how to add additional filetypes in the WordPress Media Library.
Adding a single filetype looks like this:
function my_mime_types($mime_types){ $mime_types['zip'] = 'application/zip'; return $mime_types; } add_filter('upload_mimes', 'my_mime_types', 1, 1);
In this example, zip is the file extension and application/zip is the MIME type.
You can also add multiple filetypes:
function my_mime_types($mime_types){ $mime_types['zip'] = 'application/zip'; $mime_types['tiff'] = 'image/tiff'; $mime_types['bmp'] = 'image/bmp'; return $mime_types; } add_filter('upload_mimes', 'my_mime_types', 1, 1);
How to Remove Filetypes from the WordPress Media Library
To remove default filetypes allowed by WordPress, we use the unset function.
function my_mime_types($mime_types){ unset($mime_types['pdf']); // Removes the .pdf extension return $mime_types; } add_filter('upload_mimes', 'my_mime_types', 1, 1);
You can add & remove filetypes all in the same code block. Just list each file type (addition or removal) on its own line.
List of WordPress Accepted Filetypes
Please note: Even though WordPress allows it, your web hosting company might not. If you cannot upload a file on this list, please contact your web host.
Images
.jpg, .jpeg
.png
.gif
Documents
.pdf (Adobe Acrobat Portable Document Format)
.doc, .docx (Microsoft Word Document)
.ppt, .pptx, .pps, .ppsx (Microsoft Powerpoint Presentation)
.xls, xlsx (Microsoft Excel Spreadsheet)
.odt (OpenDocument Text Document)
Audio
.mp3
.m4a
.ogg
.wav
Video
.mp4, .m4v (aka: MPEG-4)
.mov (QuickTime)
.wmv (Windows Media Video)
.avi
.mpg
.ogv (aka: Ogg)
.3gp (aka: 3GPP)
.3g2 (aka: 3GPP2)
With the ability to manage file types in WordPress Media Library, you gain control over the types of media content your website can handle.
By manage file types in WordPress Media Library, you can ensure compatibility, security, and optimal user experience.
Whether you opt for plugins or custom modifications, manage file types in WordPress Media Library has never been easier.
Embrace the flexibility and make your media management journey a seamless one. Happy uploading!
Once you have added or removed a filetype from the allowed filetypes, you will need to clear your browser’s cache before the changes will take effect.
Here are some additional tips for manage file types in WordPress media library:
- When adding a filetype to the allowed filetypes, you need to specify the MIME type for the file. You can find a list of MIME types here: https://www.iana.org/assignments/media-types/media-types.xhtml
- When removing a filetype from the allowed filetypes, you need to make sure that you are removing the correct MIME type. If you remove the wrong MIME type, you may prevent yourself from uploading certain files to your WordPress site.
- It is a good idea to test your changes before you make them public. You can do this by uploading a file of the filetype that you have added or removed from the allowed filetypes. If the file uploads successfully, then your changes have worked.
Hope this article helps you to manage file types in WordPress media library!