Skip to content

Instantly share code, notes, and snippets.

@someguy9
Created March 17, 2020 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save someguy9/44908eb8c7eef5cf957a0c82852a99ab to your computer and use it in GitHub Desktop.
Save someguy9/44908eb8c7eef5cf957a0c82852a99ab to your computer and use it in GitHub Desktop.
Enable SVG upload in WordPress
<?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