Development

How to upload SVG files to WordPress safely (with a single plugin)

If you have ever tried to upload an .svg file to the WordPress media library, you have probably come across this message:

“This file is not allowed for security reasons.”

WordPress blocks SVGs by default for a very good reason: SVG files can contain malicious JavaScript. More generally, it is worth keeping an eye on plugins that can increase your security risk. That is why it is important to handle SVGs the right way.

🔍 Why use SVG in WordPress?

SVGs are perfect for logos, icons and vector graphics:

  • They are lightweight
  • They stay sharp at any resolution
  • They can be animated and styled with CSS

But they must be safe.


🔐 The solution: the Safe SVG plugin

To enable SVG uploads safely and automatically, I recommend the free Safe SVG plugin.

✅ What Safe SVG does:

  • Lets you upload .svg files to your library
  • Automatically sanitises the SVG code, removing potentially dangerous elements
  • Works seamlessly with Elementor and other page builders

🚀 How to install it:

  1. Go to Plugins > Add New
  2. Search for “Safe SVG”
  3. Install and activate it

Done! From now on you can upload your SVG files with peace of mind.


🧯 Warning: avoid unsanitised solutions

Some articles suggest adding a snippet to functions.php to enable SVGs.
I advise against it, because WordPress will then perform no security checks on the file.
👉 If you use unsanitised SVGs, you could expose your site to XSS (cross-site scripting) vulnerabilities.


✅ In short

  • Use SVGs for a lighter, more scalable site
  • Do it safely, with the Safe SVG plugin
  • Avoid DIY solutions that skip the protection measures

Have you tried Safe SVG yet? If you want to look at the performance side too, you will find more tips on optimisation and speed.

Do you have a project to build or to put back in order?

Let's talk