Skip to content

Instantly share code, notes, and snippets.

@yuliyang
Last active November 1, 2018 07:49
Show Gist options
  • Save yuliyang/157cc106c06dc52e049d0a64c3522efd to your computer and use it in GitHub Desktop.
Save yuliyang/157cc106c06dc52e049d0a64c3522efd to your computer and use it in GitHub Desktop.
[WordPress] Allow uploading SVG files
<?php
// allow more file types for uploads
function cc_mime_types($mimes)
{
$mimes['zip'] = 'application/zip';
$mimes['rar'] = 'application/x-rar-compressed';
$mimes['tar'] = 'application/x-tar';
$mimes['gz'] = 'application/x-gzip';
$mimes['gzip'] = 'application/x-gzip';
$mimes['tiff'] = 'image/tiff';
$mimes['tif'] = 'image/tiff';
$mimes['bmp'] = 'image/bmp';
$mimes['svg'] = 'image/svg+xml';
$mimes['psd'] = 'image/vnd.adobe.photoshop';
$mimes['ai'] = 'application/postscript';
$mimes['indd'] = 'application/x-indesign'; // not official, but might still work
$mimes['eps'] = 'application/postscript';
$mimes['rtf'] = 'application/rtf';
$mimes['txt'] = 'text/plain';
$mimes['wav'] = 'audio/x-wav';
$mimes['csv'] = 'text/csv';
$mimes['xml'] = 'application/xml';
$mimes['flv'] = 'video/x-flv';
$mimes['swf'] = 'application/x-shockwave-flash';
$mimes['vcf'] = 'text/x-vcard';
$mimes['html'] = 'text/html';
$mimes['htm'] = 'text/html';
$mimes['css'] = 'text/css';
$mimes['js'] = 'application/javascript';
$mimes['ico'] = 'image/x-icon';
$mimes['otf'] = 'application/x-font-otf';
$mimes['ttf'] = 'application/x-font-ttf';
$mimes['woff'] = 'application/x-font-woff';
$mimes['ics'] = 'text/calendar';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment