Scotts Web Dev Banner
Did you notice... every article on this site has an associated video? Consider subscribing to Scotts Web Dev on YouTube! :)

Enable SVG Support In WordPress

You Should Be Using SVG’s On Your Website

It’s good practice to use SVG images on your website. They are usually small in filesize, can be animated, and scale infintely without being blurry like regular jpg, gif’s or pngs.

They are ideal for logos and icons.

WordPress Does Not Support SVG’s Natively

Unfortunately, WordPress will not allow you to upload SVG’s out of the box due to security concerns. But this does not mean that you can’t use them. You can hard code the images in your webpage’s HTML. And, if you need to upload them to WordPress’s media library, there’s an easy code snippet that will allow you to do so.

How To Enable SVG Support In WordPress

Place the following code snippet in your themes functions.php file (or your child theme, if you don’t own the theme).

/**
* Scottsweb.dev
* Allow SVG support
*/
function swd_mime_types($mimes) {
    $mimes['svg'] = 'image/svg+xml';
    return $mimes;
 }
 add_filter('upload_mimes', 'swd_mime_types');

You Can Now Use SVG’s In WordPress Media Library

After adding the above snippet you can now upload and manage SVG’s using the WordPress media library.