This plugin hasn’t been tested with the latest 3 major releases of WordPress. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

Safe SVG


Safe SVG is the best way to Allow SVG Uploads in WordPress!

It gives you the ability to allow SVG uploads whilst making sure that they’re sanitized to stop SVG/XML vulnerabilities affecting your site.
It also gives you the ability to preview your uploaded SVGs in the media library in all views.

Loving Safe SVG? Try the Pro version for extra features.

Free Features

  • Sanitised SVGs – Don’t open up security holes in your WordPress site by allowing uploads of unsanitised files.
  • View SVGs in the Media Library – Gone are the days of guessing which SVG is the correct one, we’ll enable SVG previews in the WordPress media library.

Pro Features

  • SVGO Optimisation – You’ll have the option to run your SVGs through our SVGO server on upload to save you space.
  • Choose Who Can Upload – Restrict SVG uploads to certain users on your WordPress site or allow anyone to upload.
  • Premium Support – Pro users get premium support whilst free support is offered in the WordPress forums in our spare time

Initially a proof of concept for #24251

SVG Sanitization is done through the following library:


Install through the WordPress directory or download, unzip and upload the files to your /wp-content/plugins/ directory


Can we change the allowed attributes and tags?

Yes, this can be done using the svg_allowed_attributes and svg_allowed_tags filters.
They take one argument that must be returned. See below for examples:

add_filter( 'svg_allowed_attributes', function ( $attributes ) {

    // Do what you want here...

    // This should return an array so add your attributes to
    // to the $attributes array before returning it. E.G.

    $attributes[] = 'target'; // This would allow the target="" attribute.

    return $attributes;
} );

add_filter( 'svg_allowed_tags', function ( $tags ) {

    // Do what you want here...

    // This should return an array so add your tags to
    // to the $tags array before returning it. E.G.

    $tags[] = 'use'; // This would allow the <use> element.

    return $tags;
} );


January 12, 2022
I used to install this plugin on all clients' websites, but sadly, the plugin has been not upgraded for 2 years! so i replaced it for another one
November 18, 2021
WP should incorporate this plugin asap. SVG support is now common everywhere and we still have to rely on a plugin that is no longer maintained and is clearly the best IMHO.
April 29, 2021
Just loved the plugin. Used it on a couple of website. Never failed me. Thanks to the developers who did a wonderful job.
April 12, 2021
So i've been using this for while since i switched to using a lot of svg's on my websites but iv noticed that although it allows svg's to be uploaded to the library but when i export & import my divi theme and builder page layout on to different domains or subdomains then the SVG's don't even get uploaded onto th library even when the layout gets exported and imported- this means only png's and jpg's are get uploaded leaving behind the SVG which makes me think if they were ever exported into the layout to start with. So the logic i followed whilst testing this was pretty straight forwards . i had the plugin enabled at all times whilst exporting the layout and then first thing i did was enable it on the other website before importing the divi library layout or even the divi page export layout for that matter. This issue only exists when importing & exporting layouts between different domains and never within the same domain itself. This really left me in a fix and i experienced hours of frustration finding my svg's and uploading them separately into the new website and then relinking them with the new url's. Any help and suggestions are much appreciated. I wrote to ET about this as well but they replied that since the function of SVG is controlled by the Safe svg plugin id just have to raise this issue with you. Also if the developer can be kind enough to let me know if the free version allows for inline Gutenberg block builder usage of the svg or if this issue that i'm having is because im using this free version of this plugin. UPDATED - SOLVED - 30 MINS LATER- I can now officially confirm that iv received the green signal from Divi support itself that this is a Divi problem and they're trying to fix it. So sorry if i caused any inconvenience but please delte this review as im not getting any option to do so. Although iv converted my review to a five star so it doesnt really affect the credibility of this wonderful plugin.
February 3, 2021
Great little plugin, ideal for displaying SVG brand logo images as part of a logo wall. Seems to work fine with Divi and WP 5.6. Thanks developers!
Read all 62 reviews

Contributors & Developers

“Safe SVG” is open source software. The following people have contributed to this plugin.


Translate “Safe SVG” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.



  • Fixed issue where 100% width is accidentally converted to 100px width. Props @joehoyle


  • Underlying library update


  • Underlying library update


  • Underlying library update that fixes a security issue


  • Underlying library update that fixes some security issues


  • Fixed a bug causing lots of error log output to do with safe_svg::fix_direct_image_output()


  • Fixed a bug causing 0 height and width SVGs


  • Fixed a warning about an Illegal string offset
  • Fixed an issue if something other than a WP_Post object is passed in via the wp_get_attachment_image_attributes filter.


  • Fixed a warning that was being generated by a change made in 1.9.0.


  • If an image is the correct ratio, allow skipping of the crop popup when setting header/logo images with SVGs.


  • Don’t let errors break upload if uploading an empty file
  • Fix featured image display in Gutenberg. Props @hendridm 🙂


  • Pull SVG dimensions from the width/height or viewbox attributes of the SVG.
  • Add the role=”img” attribute to SVGs


  • Updated underlying lib and added new filters for filtering allowed tags and attributes


  • Images will now use the size chosen when inserted into the page rather than default to 2000px everytime.


  • Fairly big new feature – The library now allows <use> elements as long as they don’t reference external files!
  • You can now also embed safe image types within the SVG and not have them stripped (PNG, GIF, JPG)


  • 1.5.2 introduced an issue that can freeze the media library. This fixes that issue. Sorry!


  • Tested with 4.9.0
  • Fixed an issue with SVGs when regenerating media


  • Fix PHP strict standards warning


  • Library update
  • role, aria- and data- attributes are now whitelisted to improve accessibility


  • Fixes some issues with defining the size of an SVG.
  • Library update


  • SVGs now display as featured images in the admin area


  • WordPress 4.7.3 Compatibility
  • Expanded SVG previews in media library


  • Added a check / fix for when mb_* functions are not available


  • Updated underlying library to allow attributes/tags in all case variations


  • Added ability to preview SVG on both grid and list view in the wp-admin media area
  • Updated underlying library version


  • A fix for SVGZ uploads failing and not sanitising correctly


  • Allow SVGZ uploads


  • Fix for the mime type issue in 4.7.1. Mad props to @lewiscowles


  • Updated underlying library version


  • Minify SVGs after cleaning so they can be loaded correctly through file_get_contents


  • Added support for camel case attributes such as viewBox


  • Fixed an issue with empty svg elements self-closing


  • Added i18n
  • Added da, de ,en, es, fr, nl and ru translations
  • Fixed an issue with filename not being pulled over on failed uploads


  • Initial Release