Media – Allow SVG Media Logo Upload

Woocommerce Single Product Page Snippet

With the popularity of SVG images WordPress pre 5 does not allow for the file extension SVG to be uploaded to the media library nor theme customizer logos.

The snippet below forces WordPress to allow SVG files for upload. To use the snippet:

Implementation

1. Either code and paste the code into your themes functions.php or child theme
2. If you are not that technical then install the WordPress Snippets plugin

/**
 * @snippet     WordPress Media Snippet - Media - Allow SVG Media Logo Upload
 * @code        https://techskilled.co.uk/snippets/wordpress-allow-svg-media-logo-upload-snippet
 * @author      https://techskilled.co.uk
 */
 
 function ts_mime_types($mimes) {
    $mimes['svg'] = 'image/svg+xml';
    return $mimes;
}
add_filter('upload_mimes', 'ts_mime_types');

View on snippet on GitHub.

NEED HELP?

If you are struggling to implement the SVG snippet then we can help from £9.99 – use our contact form below and we will get straight back to you!

HELP ME IMPLEMENT THIS SNIPPET

Leave a comment

Shares