|

How to upload SVG files to WordPress Media Section?

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:

function cc_mime_types($mimes) {
$mimes[‘svg’] = ‘image/svg+xml’;
return $mimes;
}
add_filter(‘upload_mimes’, ‘cc_mime_types’);

If this snippet of code helped you, give us a thumbs up by following us at: Twitter and Facebook.

Reference for Definition:
https://www.lifewire.com/svg-file-4120603