SVG formats have become very popular lately, and a lot of websites have started using them, especially for their logos.
Unfortunately, WordPress doesn’t support SVG files by default, for security reasons.
If you try to upload an SVG file in WordPress, you’ll get this error in the Media Library:
“image.svg” has failed to upload.
Sorry, this file type is not permitted for security reasons.
This doesn’t mean that all SVG files are completely unsafe and you need to avoid them. It depends on what level of security those files have.
The plugin that I’ll recommend below will sanitize the SVG files, making them safer.
Enable SVG Files in WordPress with the Safe SVG Plugin
You can watch the video or continue reading the post. Make sure you read the note at the end of the post, though.
Basically, all you have to do is to install the Safe SVG plugin. It doesn’t have any options, it works out-of-the-box.
The plugin will enable support for SVG files in WordPress and it will also sanitize them to prevent SVG/XML vulnerabilities.
It will also allow you to preview your SVG images in the Media Library, as normal images are previewed.
The SVG images will also be previewed in the Gutenberg editor.
The Safe SVG plugin also has a Pro version that additionally offers:
- SVGO optimization;
- Option to choose what users can upload SVG files;
- Premium support.
How the SVG file is created is also important.
For example, I created an SVG image using an online tool, but it doesn’t work.
It let me upload it, but it doesn’t display it in the Media Library nor the front-end.
That’s a Wrap
Hopefully, this guide helped you to enable and upload SVG files in WordPress!
If you need help setting up your WordPress site, my WordPress services are at your disposal!
You can quickly subscribe to my newsletter by using this link.
If you have any questions or thoughts, drop a comment or send a message via contact or Facebook page.
Don’t forget to share the post to help out others!