Paulund
2012-06-12 #wordpress

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.

You are currently allowed to upload images, documents, audio and video. Here are the current file formats you are allowed to upload.

Images

  • .jpg
  • .jpeg
  • .png
  • .gif

Documents

  • .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)

If the file that you want to upload is not in the above list then you will not be able to upload the file.

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',
                        'svg' => 'image/svg+xml'
        ));
    }

This function will run when Wordpress looks to get the available mime types it will then merge the current mime types with the new mime types you want to add.

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( $mimes['mp4'] );
    }

This function does the opposite of the above, it will also run at the same time but instead of adding mime types to the existing mime types it will remove them from the returning array.

List Of Mime Types To Use

Extensions Media type
.au audio/basic
.avi video/msvideo, video/avi, video/x-msvideo
.bmp image/bmp
.bz2 application/x-bzip2
.css text/css
.dtd application/xml-dtd
.doc application/msword
.docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
.dotx application/vnd.openxmlformats-officedocument.wordprocessingml.template
.es application/ecmascript
.exe application/octet-stream
.gif image/gif
.gz application/x-gzip
.hqx application/mac-binhex40
.html text/html
.jar application/java-archive
.jpg image/jpeg
.js application/x-javascript
.midi audio/x-midi
.mp3 audio/mpeg
.mpeg video/mpeg
.ogg audio/vorbis, application/ogg
.pdf application/pdf
.pl application/x-perl
.png image/png
.potx application/vnd.openxmlformats-officedocument.presentationml.template
.ppsx application/vnd.openxmlformats-officedocument.presentationml.slideshow
.ppt application/vnd.ms-powerpointtd>
.pptx application/vnd.openxmlformats-officedocument.presentationml.presentation
.ps application/postscript
.qt video/quicktime
.ra audio/x-pn-realaudio, audio/vnd.rn-realaudio
.ram audio/x-pn-realaudio, audio/vnd.rn-realaudio
.rdf application/rdf, application/rdf+xml
.rtf application/rtf
.sgml text/sgml
.sit application/x-stuffit
.sldx application/vnd.openxmlformats-officedocument.presentationml.slide
.svg image/svg+xml
.swf application/x-shockwave-flash
.tar.gz application/x-tar
.tgz application/x-tar
.tiff image/tiff
.tsv text/tab-separated-values
.txt text/plain
.wav audio/wav, audio/x-wav
.xlam application/vnd.ms-excel.addin.macroEnabled.12
.xls application/vnd.ms-excel
.xlsb application/vnd.ms-excel.sheet.binary.macroEnabled.12
.xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xltx application/vnd.openxmlformats-officedocument.spreadsheetml.template
.xml application/xml
.zip application/zip, application/x-compressed-zip