Last active
September 9, 2022 14:33
-
-
Save terrytsang/68614959e1efccc0bc9419b0641ddd2e to your computer and use it in GitHub Desktop.
Allow WordPress admin to upload SVG media file
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 | |
//below code snippet is to be added to WordPress theme functions.php file | |
//enable SVG upload | |
function tt_enable_svg_upload( $mimes ) { | |
//Only admin can upload SVG file | |
if ( !current_user_can( 'administrator' ) ) { | |
return $mimes; | |
} | |
$mimes['svg'] = 'image/svg+xml'; | |
$mimes['svgz'] = 'image/svg+xml'; | |
return $mimes; | |
} | |
add_filter('upload_mimes', 'tt_enable_svg_upload'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment