Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Enable SVG file upload through WordPress Media Uploader
* Add the SVG Mime type to the uploader
* @author Alain Schlesser (
* @param array $mimes list of mime types that are allowed by the
* WordPress uploader
* @return array modified version of the $mimes array
* @see
* @see
function as_svg_mime_type( $mimes ) {
// add official SVG mime type definition to the array of allowed mime types
$mimes['svg'] = 'image/svg+xml';
// return the modified array
return $mimes;
add_filter( 'upload_mimes', 'as_svg_mime_type' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.