Are you having a problem with uploading SVG image on your WordPress Website? Don’t worry, this is a common problem because WordPress does not support uploading SVG by default, which is mainly for security reasons. Today We will talk about this problem in detail and how to deal with it in the future.
Table of Contents
What is SVG Images?
SVG ( Scalable Vector Graphics ) is a vector image format based on XML text. JPG and PNG are common image formats made up of a lot of tiny squares called pixels. But the SVG image format relies on XML tags to describe lines, shapes, and other image attributes.
SVG did not become popular until recent years, although it has been around since the 90s. W3Techs statistics show that as of March 2020, only 22.7% of all websites use SVG. However, this number may increase as developers and website owners try to meet the current demand for scalability and fast loading speeds (we will explain why later).
Another advantage of SVG is that it has extensive support and works on all major browsers (such as Chrome, Firefox, Safari, and Chrome for Android)!
Unfortunately, people using IE8 or earlier versions of Chrome and Safari may run into issues because the format no longer supports these browsers. But this should not be a problem for webmasters, as most people no longer use these outdated browsers.
Why should SVG Image use more commonly?
Many people are still unfamiliar with the SVG format because it is not as popular as pixel graphics. But this is not the case, because this graphics format has many benefits.
The first outstanding advantage of SVG is its scalability. Because SVGs are vector-based, they maintain the same quality at all screen resolutions.
If a JPG file appears blurry on a particular device due to insufficient size, SVG still looks very sharp. You can even zoom in and out at will without losing any quality. This particular feature is really helpful when creating the same high-quality user experience for all your website visitors.
SVG is also known for its small files. As a result, they take up less web storage space and load faster than pixel images. But there is a catch-if you take a sufficiently detailed image and convert it to SVG, it will take up more space than JPG or PNG.
why is it like this? Well, this is because the file size of SVG depends on the complexity of the image. The more detailed the image, the larger the file. That’s why SVG is better suited for logos and icons. If you want to display very detailed images (such as photos) on your website, JPG and PNG are better ways.
Another great feature for webmasters is Google’s indexing of SVG. All images in this format will be displayed in Google Image Search, which will greatly improve the SEO of your website.
Why WordPress Not Support SVG Image?
With so many advantages, why is SVG uncommon? Why doesn’t WordPress allow us to easily upload SVG?
The main reason why WordPress still does not include SVG as part of its core (default file) is due to its security risks.
Since SVGs are basically text files, people can easily take advantage of them by inserting malicious code. As a result, your site has a chance of an injection attack, which can lead to catastrophic site hacking. Very scary, isn’t it?
That’s why you need to be careful when working with SVG files. If you are uploading SVG to WordPress, it is important to do it the right way-especially if you are uploading SVG files that are freely available from unknown sources.
The solution to prevent harmful code is to clean up the malicious code of SVG files. This process eliminates suspicious code and errors and makes images safe for your website. Random uploading SVGs of unknown origin to WordPress can lead to serious consequences (such as hacked websites and server crashes).
Discussions about making SVG a part of WordPress’s core features are still ongoing. Therefore, we currently need to take some extra actions to upload SVG to WordPress.
How to upload SVG files to WordPress securely
The best way to safely upload SVG files to WordPress is to use Safe SVG, a plugin that automatically cleans up uploaded SVG files. In addition, it can preview SVG files in the media library, so you can easily add them to your articles.
This WordPress plugin also has a professional version that allows limiting the users who can upload SVG. This feature is useful for sites with multiple contributors, as you can restrict access to people you trust.
Professional edition also includes SVGO Optimized Server, which allows you to reduce file size and get advanced support. And Who Can Upload.
You can download the plugin at https://wordpress.org/plugins/safe-svg/ When you install and activate the plugin, you do not need to make any settings adjustments. It only allows SVG uploads, while automatically cleaning up potentially malicious code.
Here is an example where I tried to upload an SVG image before installing Safe SVG plugin. As you can see, WordPress does not allow this because of security issues.
But after installing Safe SVG, we can easily upload it. And we can even see a preview of the image.
That’s it! It turns out that uploading SVG files to WordPress is not difficult, right?
To sum up
SVG has many advantages for your WordPress website. However, due to its text formatting, people may insert an injection code and make your website vulnerable. This is the main reason why WordPress does not allow its users to upload SVG by default.
And we can use Safe SVG plugin to upload SVG files and delete all malicious code at the same time.
With the help of the Safe SVG plugin, although it is very secure, we recommend that you should be careful. If you want to download any free SVG images, always check if they come from a trusted and reliable source. be careful! It is recommended that you download the SVG icon at