How to Add SVG Support in WordPress Website
Trying to upload SVG files to WordPress and running into errors like “Sorry, this file type is not permitted for security reasons”?
You’re not alone. By default, WordPress blocks SVG uploads because SVGs are XML-based files, which could be exploited if not properly sanitized.
But don’t worry, adding SVG support is simple. Here’s exactly how you can enable SVG uploads safely and easily on your WordPress website.
How to Add SVG Support in WordPress
- Introduction
- How to Safely Add SVG Support in WordPress
- 1. Use a Trusted SVG Plugin
- 2. Enable SVG Uploads Manually with Code
- Best Practices for Using SVG Files in WordPress
- Common SVG Upload Issues and How to Fix Them
- Why WordPress Doesn’t Support SVG by Default
- FAQS – How to Add SVG Support in WordPress
- Final Thoughts
1. Add SVG Support Using a Plugin (Quick and Safe)
The easiest and safest way to allow SVG uploads in WordPress is by using a trusted plugin.
This method ensures security because most SVG plugins sanitize the files automatically before upload.
Recommended Plugins:
- Safe SVG: Safe SVG is one of the most popular and trusted plugins for WordPress SVG upload support. It automatically sanitizes SVG files to remove harmful code.
- SVG Support: SVG Support is another powerful option that allows you to upload and embed SVG files with advanced settings like inline rendering.
Steps to Add SVG Support Using a Plugin:
- Go to your WordPress dashboard.
- Navigate to Plugins → Add New.
- Search for Safe SVG or SVG Support.
- Install and activate the plugin.
- That’s it. Now you can easily upload SVG files through your Media Library.

Always choose SVG plugins that automatically sanitize files. This ensures your WordPress site stays protected from hidden security threats.
2. Add SVG Support Manually (Developer-Friendly)
If you prefer a lightweight method without plugins, you can manually add SVG support in WordPress by inserting a small code snippet.
However, be careful: manually allowing SVG uploads without proper sanitization can expose your site to security vulnerabilities.
Here’s How to Enable SVG Uploads Manually:
- Open your theme’s
functions.php
file.
(Preferably using a child theme if you are working with a custom WordPress Theme Creator tool or if you plan to create a WordPress Theme manually.) - Add the following code snippet:
function add_file_types_to_uploads($file_types){
$new_filetypes = array();
$new_filetypes['svg'] = 'image/svg+xml';
return array_merge($file_types, $new_filetypes);
}
add_filter('upload_mimes', 'add_file_types_to_uploads');
- Save the changes.
Now, you’ll be able to upload SVG files directly to your WordPress Media Library.
Best Practices for Uploading SVGs in WordPress
While enabling SVG support is easy, you must follow some best practices to maintain the security and performance of your site.
Sanitize SVG Files:
- SVGs are basically XML files, meaning malicious code can be injected.
- Always sanitize SVG files before uploading.
- Use online tools like SVG Sanitizer or ensure your plugin sanitizes automatically.
Restrict Uploads:
- Limit SVG uploads only to trusted user roles like Admins.
- You can customize file upload permissions by adding extra code snippets or using plugins like User Role Editor.
Optimize SVGs:
- SVGs are generally lightweight, but optimizing them can improve load speed.
- Tools like SVGO or SVGOMG can help compress SVG files without losing quality.
Use SVGs Smartly:
- SVGs are perfect for logos, icons, and vector illustrations.
- You can use them creatively when designing or customizing your Free WordPress Themes to enhance design flexibility.
This guide is designed to help you add SVG support safely without risking your website’s security. Always back up your site before making changes.
Common Problems and Fixes When Uploading SVG Files
Even after enabling SVG support, you might face some small issues. Here’s how to fix them:
- Problem: SVGs still not uploading?
Fix: Double-check MIME type settings. Some web hosts block certain MIME types at the server level. - Problem: SVGs look broken or are not rendering properly?
Fix: Ensure that your theme supports inline SVG rendering. Some themes or page builders might strip or block certain XML elements. - Problem: Security scanner flags issues with SVGs?
Fix: Always sanitize SVG files manually or use a security-focused plugin to handle uploads.
Why WordPress Doesn’t Support SVG by Default
While SVG (Scalable Vector Graphics) files offer incredible benefits like smaller file sizes, responsiveness, and crisp visuals at any resolution, WordPress doesn’t support SVG uploads by default for security reasons.
The main concern lies in how SVG files are structured. Unlike traditional image formats like JPG or PNG, an SVG is an XML-based file, which means it’s essentially code. If improperly crafted or uploaded without sanitization, an SVG could potentially contain malicious scripts leading to serious vulnerabilities such as:
- Cross-site scripting (XSS) attacks: Hackers could inject harmful JavaScript into an SVG that, when uploaded and viewed on a site, compromises user data or control.
- Site defacement: Unsanitized SVGs can be manipulated to alter website layouts, redirect users, or damage your site’s credibility.
- Sensitive information leaks: Bad actors might embed hidden requests inside an SVG, leading to unauthorized data access.
Given WordPress’s wide adoption, the platform chooses security-first defaults. By blocking SVG uploads out-of-the-box, WordPress protects users, especially non-technical site owners, from unintentionally introducing risks.
FAQs
Q1. Is it safe to upload SVGs to WordPress?
SVGs are safe if sanitized properly before uploading. Always use a trusted plugin that sanitizes SVG files automatically.
Q2. What is the best plugin to enable SVG uploads in WordPress?
Safe SVG and SVG Support are two of the best plugins to allow and sanitize SVG uploads securely.
Q3. Should I manually add SVG support to WordPress?
If you’re comfortable with coding and handling security risks, you can manually allow SVG uploads. Otherwise, using a plugin is strongly recommended.
Conclusion: Safely Enable SVG Support in WordPress
Adding SVG support to WordPress is quick and easy, whether you choose to use a plugin or add a few lines of code manually.
For most users, installing a plugin like Safe SVG is the best and safest option, especially when dealing with a live production site.
And if you’re a developer working with a WordPress Theme Creator tool or looking to create a WordPress theme from scratch, adding SVG support manually gives you better control.
Build a Stunning Website in Minutes with TemplateToaster Website Builder
Create Your Own Website Now
Great guide! One thing I found useful when adding SVGs manually was to restrict upload permissions to admin roles only, just to tighten security a bit more.