By default, WordPress supports only a few types of images for the website. Despite the popularity of SVG files, WordPress is yet to support them.
How can you upload SVG in WordPress? In this article, we would like to discuss what is SVG and how to upload SVG in WordPress.
What is SVG?
SVG is short for Scalable Vector Graphics that are based in XML and often are used in interactive or animated pictures. WordPress comes with many features and it allows you to upload popular formats for images, audio and video files. However, it doesn’t support SVG files.
SVG allows you to enlarge pictures without losing their quality. In normal ordinary image formats like JPEG and PNG when you zoom in, you may see the pixels of the image, but in SVG format as much as you zoom in there are no pixels to see.
Vector images are usually used for logos, icons and icon fonts. As useful as SVG may sound, WordPress doesn’t support it due to some security reasons.
If you try to upload an SVG file, you will see the following error:
Are SVG files safe?
As mentioned above, SVG files are based on XML. XML is similar to HTML. The browser or website reads SVG based on XML and displays them to you.
XML itself isn’t safe and it could leave potential gateway for brute force attacks or script attacks which is a nightmare for any website owner.
We highly recommend uploading safe SVG files; Which you have downloaded from a safe and reliable source. Otherwise, malicious codes will be uploaded to your website and you may lose the website.
How to Upload SVG in WordPress?
As you probably know, WordPress is very flexible when it comes to adding or removing functionality. To upload SVG files in WordPress, we’re going to use the SVG Support plugin.
Below we will mention a few trusted plugins you can use to upload SVG in WordPress.
There are a lot of SVG plugins out there but you must be careful which one to install. As mentioned above, some SVG files may contain malicious code and they could open up a gateway for hackers to gain access to your WordPress website.
Thus, you must be careful which plugin you install and which SVG file gets uploaded to the website. We highly recommend downloading WordPress security plugins to prevent any issues.
To download the SVG Support plugin, you can either download it directly from the official WordPress website or from the WordPress Dashboard itself. Simply, hover over Plugins and click on Add New and in the search box type in SVG Support.
Click on Install and then Activate the plugin. Once the plugin is activated, from Settings click on SVG Support to configure the plugin to match your needs.
Make sure you check the “Restrict to Administrators”. This option only allows the admin to upload SVG to WordPress. The next option is the advanced mode. This mode gives you the ability to add CSS animation and SVG rendering.
Make sure to save changes once you are done.
Now head over to one of your posts or simply create a new one. If you are using the Gutenberg editor create an image block and upload the SVG image.
Upload SVG in WordPress By Safe SVG
Safe SVG is another safe plugin you can use to upload SVG files to WordPress. The first thing to do is to download the plugin. You can either download it from the official WordPress website or directly from the WordPress Dashboard.
Simply, hover over the Plugins and click on Add New. In the search box type in Safe SVG and press enter. Then, install and activate the plugin.
The plugin is already configured. Thus, there are no settings. The plugin works out of the box. You can easily upload SVG files to WordPress and use them in an existing post or create a new post.
Enable SVG
Enable SVG is yet another plugin that gives you the option to upload SVG files to WordPress. Besides, it comes with a validator. It checks the XML file to make sure there is no malicious code in the file.
However, it may not be as good as a security plugin but it still can reduce the risks of dangerous software.
Conclusion
In this article, we talked about SVG and how to upload SVG in WordPress. SVG files are based on XML and by using them on WordPress, you put the website at risk of getting hacked. Therefore, it’s a must to download some kind of security plugin to prevent any malicious software injecting code on your website.