Created
March 17, 2020 12:44
-
-
Save someguy9/44908eb8c7eef5cf957a0c82852a99ab to your computer and use it in GitHub Desktop.
Enable SVG upload in WordPress
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 | |
//Enable SVG upload | |
function smartwp_enable_svg_upload( $mimes ) { | |
//Only allow SVG upload by admins | |
if ( !current_user_can( 'administrator' ) ) { | |
return $mimes; | |
} | |
$mimes['svg'] = 'image/svg+xml'; | |
$mimes['svgz'] = 'image/svg+xml'; | |
return $mimes; | |
} | |
add_filter('upload_mimes', 'smartwp_enable_svg_upload'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment