How can I upload SVG images using the media uploader?

You need to filter the allowed upload file types and add the SVG filetype to the list:

function allow_svg_upload_mimes( $mimes ) {
    $mimes['svg'] = 'image/svg+xml';
    return $mimes;
}
add_filter( 'upload_mimes', 'allow_svg_upload_mimes' );

Also on GitHub

Leave a Comment