0

Change WordPress Upload Mime Types

In the current WordPress install you are allowed to upload the following file types. You are only able to upload one of the following types. If the file you are trying to upload is not one of the following it will not upload.

Wordpress

Images.jpg.jpeg.png.gifDocuments.pdf (Portable Document Format; Adobe Acrobat).doc, .docx (Microsoft Word Document).ppt, .pptx, .pps, .ppsx (Microsoft PowerPoint Presentation).odt (OpenDocument Text Document).xls, .xlsx (Microsoft Excel Document)Audio.mp3.m4a.ogg.wav

Video.mp4, .m4v (MPEG-4).mov (QuickTime).wmv (Windows Media Video).avi.mpg.ogv (Ogg).3gp (3GPP).3g2 (3GPP2)Add Additional Mime Types

If the file you want to upload isn’t one of the above then you can add a function into your functions.php file to allow WordPress to allow additional mime types.

add_filter(‘upload_mimes’,’add_custom_mime_types’);
function add_custom_mime_types($mimes){
return array_merge($mimes,array (
‘ac3′ => ‘audio/ac3′,
‘mpa’ => ‘audio/MPA’,
‘flv’ => ‘video/x-flv’
));
}
Remove Existing Mime Types

You can also do the opposite of adding custom mime types by removing the default mime types, for example if you don’t want your users to upload video then you can remove the video mime type.

add_filter(‘upload_mimes’,’remove_mime_types’);
function remove_mime_types($mimes){
unset( $existing_mimes[‘mp4’] );
}

This article was original wrote on Change WordPress Upload Mime Types


 

Leave a reply