matthijs166
9/22/2017 - 9:15 PM

Add more file types wordpress

add more file types on wordpress

// Added to extend allowed files types in Media upload
add_filter('upload_mimes', 'custom_upload_mimes');
function custom_upload_mimes ( $existing_mimes=array() ) {
  
  // Add *.EPS files to Media upload
  $existing_mimes['eps'] = 'application/postscript';
  
  // Add *.AI files to Media upload
  $existing_mimes['ai'] = 'application/postscript';
  
  $existing_mimes['eot'] = 'application/vnd.ms-fontobject';
	$existing_mimes['woff'] = 'font/woff';
	$existing_mimes['woff2'] = 'font/woff2';
	$existing_mimes['ttf'] = 'application/octet-stream';
	$existing_mimes['svg'] = 'font/svg';
	
  $mime_types['zip'] = 'application/zip';
  $mime_types['rar'] = 'application/x-rar-compressed';
  $mime_types['tar'] = 'application/x-tar';
  $mime_types['gz'] = 'application/x-gzip';
  $mime_types['gzip'] = 'application/x-gzip';
  $mime_types['tiff'] = 'image/tiff';
  $mime_types['tif'] = 'image/tiff';
  $mime_types['bmp'] = 'image/bmp';
  $mime_types['svg'] = 'image/svg+xml';
  $mime_types['psd'] = 'image/vnd.adobe.photoshop';
  $mime_types['ai'] = 'application/postscript';
  $mime_types['indd'] = 'application/x-indesign'; // not official, but might still work
  $mime_types['eps'] = 'application/postscript';
  $mime_types['rtf'] = 'application/rtf';
  $mime_types['txt'] = 'text/plain';
  $mime_types['wav'] = 'audio/x-wav';
  $mime_types['csv'] = 'text/csv';
  $mime_types['xml'] = 'application/xml';
  $mime_types['flv'] = 'video/x-flv';
  $mime_types['swf'] = 'application/x-shockwave-flash';
  $mime_types['vcf'] = 'text/x-vcard';
  $mime_types['html'] = 'text/html';
  $mime_types['htm'] = 'text/html';
  $mime_types['css'] = 'text/css';
  $mime_types['js'] = 'application/javascript';
  $mime_types['ico'] = 'image/x-icon';
  $mime_types['otf'] = 'application/x-font-otf';
  $mime_types['ttf'] = 'application/x-font-ttf';
  $mime_types['woff'] = 'application/x-font-woff';
  $mime_types['ics'] = 'text/calendar';
  
  return $existing_mimes;
}



types {
    text/html                             html htm shtml;
    text/css                              css;
    text/xml                              xml rss;
    image/gif                             gif;
    image/jpeg                            jpeg jpg;
    application/x-javascript              js;
    application/atom+xml                  atom;

    text/mathml                           mml;
    text/plain                            txt;
    text/vnd.sun.j2me.app-descriptor      jad;
    text/vnd.wap.wml                      wml;
    text/x-component                      htc;

    image/png                             png;
    image/tiff                            tif tiff;
    image/vnd.wap.wbmp                    wbmp;
    image/x-icon                          ico;
    image/x-jng                           jng;
    image/x-ms-bmp                        bmp;
    image/svg+xml                         svg svgz;

    application/java-archive              jar war ear;
    application/mac-binhex40              hqx;
    application/msword                    doc;
    application/pdf                       pdf;
    application/postscript                ps eps ai;
    application/rtf                       rtf;
    application/vnd.ms-excel              xls;
    application/vnd.ms-powerpoint         ppt;
    application/vnd.wap.wmlc              wmlc;
    application/vnd.wap.xhtml+xml         xhtml;
    application/x-7z-compressed           7z;
    application/x-cocoa                   cco;
    application/x-java-archive-diff       jardiff;
    application/x-java-jnlp-file          jnlp;
    application/x-makeself                run;
    application/x-perl                    pl pm;
    application/x-pilot                   prc pdb;
    application/x-rar-compressed          rar;
    application/x-redhat-package-manager  rpm;
    application/x-sea                     sea;
    application/x-shockwave-flash         swf;
    application/x-stuffit                 sit;
    application/x-tcl                     tcl tk;
    application/x-x509-ca-cert            der pem crt;
    application/x-xpinstall               xpi;
    application/zip                       zip;

    # Mime types for web fonts. Stolen from here:
    # http://seconddrawer.com.au/blog/ in part.
    application/x-font-ttf                ttf;
    font/opentype                         otf;
    application/vnd.ms-fontobject         eot;
    application/x-woff                    woff;

    application/octet-stream              bin exe dll;
    application/octet-stream              deb;
    application/octet-stream              dmg;
    application/octet-stream              iso img;
    application/octet-stream              msi msp msm;

    audio/midi                            mid midi kar;
    audio/mpeg                            mp3;
    audio/x-realaudio                     ra;

    video/3gpp                            3gpp 3gp;
    video/mpeg                            mpeg mpg;
    video/quicktime                       mov;
    video/x-flv                           flv;
    video/x-mng                           mng;
    video/x-ms-asf                        asx asf;
    video/x-ms-wmv                        wmv;
    video/x-msvideo                       avi;
}