Add/Remove MIME Types in WordPress


Categories
Tags
How to add/remove MIME types to/from your WordPress site via the functions file.

This technique could be used if you’re finding that the allowed MIME types list in your WordPress settings aren’t all being adhered to for some reason. It works for WordPress Multisite too, as long as you add this to your parent theme’s functions file, assuming you want it to take effect across all of your sites.

The example code below can be used to add additional MIME types (and/or remove them) via your site’s theme’s functions file. In this example, we add the doc file type (for Microsoft Word doc files) and remove exe (executable) file types. This affects what can and can’t be uploaded to the website via the media manager.

/* Add/remove additional mime types for media library */
function edit_mime_types($mimes){

//add mime types
$mimes['doc'] = 'application/msword';

//remove mime types
unset( $mimes['exe'] );

return $mimes;
}
add_filter( 'upload_mimes', 'edit_mime_types' );

Comments

Whether you have feedback, a question, want to share your opinion, or simply want to say thank you - we welcome comments! Please read the disclaimer.

Disclaimer and Legal Information

The use of any content found on or via this website (code, how to guides etc.) is done so at your own risk. We take no responsibility for any issues encountered.

This blog and its authors will not be held responsible for any misuse, reuse, recycled and cited/uncited copies of content from this website by others.

The views and opinions expressed in this blog are those of the author(s) and do not necessarily reflect the position or opinion of any other agency, organisation, employer or company.

Comments are moderated but we do not take any responsibility for any libel or litigation that results from something written in a comment. We reserve the right to reject or delete any comment for any reason whatsoever (abusive, profane, rude etc). Please keep your comments polite and relevant.

We are happy for you to quote and share our content in any reasonable manner, e.g. post links to our blogs on social media, but not in any way that suggests that we, or our authors, endorse you, your use or your views. Nothing negative please.

We appreciate attributions, e.g. a link to our website (www.dragoncode.co.uk).

Thank you – we hope you find the website useful.