How to upload SVG files to WordPress Media Section?
Recently, got into an issue of SVG files not uploading to the media section of the WordPress.
Just to give you a recap on what is SVG file. It’s file with the SVG file extension is most likely a Scalable Vector Graphics file. Files in this format use an XML-based text format to describe how the image should appear.
Since text is used to describe the graphic, an SVG file can be scaled to different sizes without losing quality – in other words, the format is resolution independent. This is why website graphics are often built in the SVG format, so they can be resized to fit different designs in the future.
Here is the snippet of code which if you place in function.php will allow you to start uploading SVG file:
$mimes[‘svg’] = ‘image/svg+xml’;
Reference for Definition: