Created
March 8, 2014 00:05
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function custom_mtypes( $m ){ | |
$m['svg'] = 'image/svg+xml'; | |
$m['svgz'] = 'image/svg+xml'; | |
return $m; | |
} | |
add_filter( 'upload_mimes', 'custom_mtypes' ); |
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
I had to change:
$(
to
jQuery(
and fix a little image positioning
but otherwise works great, thanks man!