Skip to content

Instantly share code, notes, and snippets.

@benfrain
Created March 8, 2014 00:05
Show Gist options
  • Save benfrain/9422862 to your computer and use it in GitHub Desktop.
Save benfrain/9422862 to your computer and use it in GitHub Desktop.
Allow SVG upload and preview to Media area of Wordpress (add this to functions.php)
function custom_mtypes( $m ){
$m['svg'] = 'image/svg+xml';
$m['svgz'] = 'image/svg+xml';
return $m;
}
add_filter( 'upload_mimes', 'custom_mtypes' );
@piotrku
Copy link

piotrku commented Aug 14, 2020

I had to change:
$(
to
jQuery(
and fix a little image positioning
but otherwise works great, thanks man!

@nicholascourage
Copy link

For WordPress 5.7.2 var urlLabel = element.find('label[data-setting="url"]'); needs to be updated to : var urlLabel = element.find('span[data-setting="url"]');

I found that out the hardway but otherwise thank you very much :)

SitePoint has a similiar description that follows this way of doing it too which I also found very helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment