Upload SVG through WordPress Media Uploader

As SVG continues is rise to the top of the internet image food chain you may have found yourself wondering why WordPress gives the security smackdown when uploading SVG through the Media Uploader:


Fix it with this code, either in functions.php or better yet, your own functionality plugin:

 * Adds MIME Types to WP Media Uploader 
 * @since  1.0.0
 * @access public
 * @return void

function spigot_mime_types( $mimes ){
    $mimes['svg'] = 'image/svg+xml';
    return $mimes;

add_filter( 'upload_mimes', 'spigot_mime_types' );

One day I imagine WordPress will allow SVG uploading out of the box, but until then…

Leave a Reply

Your email address will not be published. Required fields are marked *

Ready for a refreshing experience on your next website design?