Last active
December 5, 2016 09:15
-
-
Save walterebert/23b52b7d8c19ef8a8f6c to your computer and use it in GitHub Desktop.
WordPress snippet: Allow SVG uploads
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
<?php | |
function my_allow_svg( $mimetypes ) { | |
$mimetypes['svg'] = 'image/svg+xml'; | |
$mimetypes['svgz'] = 'image/svg+xml'; | |
return $mimetypes; | |
} | |
add_filter( 'upload_mimes', 'my_allow_svg' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uploading SVG has some security risks, see: https://bjornjohansen.no/svg-in-wordpress
A better solution is to use the Safe SVG plugin: https://wordpress.org/plugins/safe-svg/