What Safe SVG does on your site
Out of the box, WordPress refuses SVG uploads, and for good reason: an SVG is an XML document that can carry JavaScript, event handlers or references to other sites. Safe SVG adds SVG and SVGZ to the accepted file types, but only for the roles you allow, and runs every file through the svg-sanitizer library before saving it. That library keeps only tags and attributes from an allowlist. If a file can't be sanitized, the upload is rejected and the file is deleted from the uploads folder.
The plugin also fixes how SVGs look in the admin: previews in every Media Library view, dimensions read from the file instead of a one-pixel image, and no intermediate image sizes. It adds an "Inline SVG" block that writes the SVG markup straight into the page, with an optional link (new tab, rel="nofollow" or rel="sponsored") and a label for screen readers.
Safe SVG is maintained by the agency 10up and grew out of work by Daryll Doyle, the author of svg-sanitizer. It's completely free, with no paid edition. An SVGO optimization step exists, but it's off by default and can only be turned on in code.
Which sites get the most out of Safe SVG
Safe SVG solves one specific problem: using crisp vector files at any size without opening the door to scripts.
- Business and brand sites: logos, icons and illustrations in SVG, uploaded by a trusted administrator or editor.
- Agencies and developers: almost nothing to explain to clients, the same behavior on every site, and documented PHP filters when you need more.
- Sites built with the block editor: the "Inline SVG" block displays an icon that picks up the surrounding text color when the SVG uses
currentColor.
It's the wrong fit if untrusted members or clients need to upload SVGs: even sanitized, an SVG is still an active document, and every account you allow widens the XSS vulnerability risk. If what you really want is more inline display options, compare it with SVG Support.
Safe SVG strengths and limitations
Strengths
- Sanitized on upload. Every SVG goes through an allowlist of tags and attributes, and a file that can't be cleaned is rejected.
- Role control. One checkbox per role that can upload files, right on the media settings screen.
- A usable Media Library. Proper previews and dimensions, without pointless intermediate sizes.
- Isolated inline block. Since version 2.5.0, an SVG that carries its own
<style>element renders inside a shadow DOM, so its styles don't leak into the page. - Free and maintained. No paid edition, and 10up publishes its security advisories with the patched versions.
Limitations
- Only two settings. SVGO optimization, stripping remote references or changing allowed tags all require PHP filters.
- No global switch. Upload forms built by other plugins may reject SVGs, a deliberate choice so that no unsanitized file gets through.
- Theme styles locked out. Theme CSS no longer reaches inline SVGs that have their own
<style>; only inherited color and custom properties get through. - A run of fixes in 2026. Three security releases between September and October 2026, so an old version is exposed.
- WordPress 6.9 or later. Since version 2.5.0, a site stuck on an older WordPress release no longer gets these fixes.
The Safe SVG settings we recommend
The interface lives under Settings > Media, in the "Safe SVG Settings" section. Everything else is a PHP filter, to add through a code snippets plugin or a child theme's functions.php file.
| Setting | Recommended value | Why |
|---|---|---|
| User Roles Settings > Media > Safe SVG Settings | Administrator, plus Editor only if needed | By default, every role that can upload files, Author included, can upload SVGs. |
| Large Files (Allow large SVG files) Same screen | Off (default) | Above 10 MB, an SVG hurts performance and rarely belongs on a web page. |
| Auto-updates Plugins > Installed Plugins, Safe SVG row | On | The latest releases are security releases the developer recommends installing right away. |
safe_svg_remove_remote_references filterPHP code | On if your SVGs use no remote fonts or images | Strips external URLs from SVGs uploaded from then on. Check how a typical file renders before rolling it out. |
safe_svg_optimizer_enabled filterPHP code | Off (default) | The optimizer rewrites the markup of uploaded files, so only turn it on after testing how your SVGs render. |
safe_svg_inline_use_shadow_dom filterPHP code | On (default) | Turning it off lets an inline SVG's CSS change the rest of the page. |
- Upload an SVG from Media > Add Media File as an administrator: the preview should show in the Media Library.
- Log in with an account whose role is unchecked: the SVG upload should be refused with an error message.
- Open an uploaded SVG in a text editor: no
<script>element oronloadattribute should remain. - Check under Plugins that the installed version is at least 2.5.2.
Safe SVG security: a sanitizer that needs patching too
A sanitizing plugin is an obvious target: bypass it and you can plant a script in the Media Library. The security advisories published by 10up mostly cover flaws that require a contributor or author account:
- Fixed in 2.2.6: SVGs added by sideloading or through the REST API could skip sanitization.
- Fixed in 2.5.0: stored CSS injection by an author account through the "Inline SVG" block (versions 2.1.0 to 2.4.0).
- Fixed in 2.5.1: two stored XSS flaws in the "Inline SVG" block, one open to contributors, plus contributors being able to read private SVGs.
- Fixed in 2.5.2: files typed as SVG over XML-RPC skipped sanitization and the role setting, with a gzip bomb risk, plus three medium or low severity issues.
What actually helps: turn on auto-updates for Safe SVG (see our guide to automatic plugin updates) and trim the list of allowed roles, following the approach in our article on WordPress roles and capabilities. WP Feint Pro removes traces of the safe-svg folder and the plugin's files from public pages, which makes it harder for bots hunting these flaws to spot the plugin, but it's no substitute for updating.
What WP Feint hides for Safe SVG
Pro Handled by WP Feint Pro only
The free version does not know the traces specific to Safe SVG: without Pro, only generator tags are removed, as for any plugin.
Free version
Handled by WP Feint Pro only
With Pro
- folder name
- tag IDs
Still visible
No known trace
Safe SVG FAQ
Is Safe SVG really free?
Yes. The plugin is distributed for free on wordpress.org and 10up doesn't sell a paid edition: every feature described here is included.
Why does another plugin's upload form reject my SVGs?
Safe SVG only allows SVGs on upload paths it knows how to sanitize, such as the Media Library and the editor. A plugin that uses its own upload path doesn't get that permission, and that's by design: allowing SVG everywhere would let unsanitized files through.
How do I turn on SVGO optimization?
Add add_filter( 'safe_svg_optimizer_enabled', '__return_true' ); through a code snippets plugin or a child theme's functions.php. SVGs uploaded after that are optimized; check how a few files render before keeping it.
My theme no longer colors an inline SVG icon. Is that expected?
Yes, if the SVG contains a <style> element: since version 2.5.0 it's isolated and theme CSS can't reach it. Use currentColor inside the SVG and set the color on a parent element, or remove the <style> element from the file.