SVG images are almost 96% supported in browsers but need a bit of backward compatibility for the 4% of stragglers, out of the box WordPress does not support the upload of SVG images via the media loader but you can circumnavigate that by adding the image format to the list of allowed types.
There is a nice javascript plugin called SVGeezy (love that name) that can check if a browser supports SVG and if it doesn’t can fall back to an alternative image in the same directory with a different file type such as .png
Download the latest version of SVGeezy and grab the svgeezy.min.js file and add to your theme’s js folder and enqueue it, also create an init file, here called svgeezy-init.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
What we are saying here is to check images and if SVG is not supported use a .png variation in the same location. Accordingly you can use another format like .jpg
You can also filter which images to check by using a CSS class on the image like so
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters