WordPress SVG Enabler

plugin banner

This plugin gives you the ability to allow SVG uploads whilst making sure that they’re sanitized to stop SVG/XML vulnerabilities affecting your site.

Author:Optimist Hub (profile at wordpress.org)
WordPress version required:6.0
WordPress version tested:7.1.3
Plugin version:2.0.0
Added to WordPress repository:27-01-2023
Last updated:04-10-2026
Rating, %:0
Rated by:0
Plugin URI:https://github.com/optimisthub/wordpress-svg-...
Total downloads:3 473
Active installs:30+
plugin download
Click to start download

SVG Enabler lets you upload SVG files to the WordPress media library while making sure each file is safe.

SVG is an XML format, which means it can carry JavaScript, event handler attributes, external references and XML entities. Uploading an unsanitized SVG is equivalent to allowing arbitrary HTML and JavaScript uploads. This plugin sanitizes every SVG during upload, before the file is written to your uploads directory.

What gets removed

  • <script> elements and inline JavaScript
  • Event handler attributes such as onload, onclick, onerror
  • javascript: URLs in links and attributes
  • <foreignObject> payloads
  • Remote references in <image>, <use>, href and xlink:href
  • Remote url() and @import rules inside <style> blocks
  • XML entities and DTD declarations (XXE)
  • CSS expression() and behavior: declarations

Features

  • SVG and SVGZ upload support
  • Sanitizes on upload, before the file reaches the uploads folder
  • Uses the actively maintained enshrined/svg-sanitize library (0.22.0+)
  • Correct image dimensions in the media library, editor and srcset
  • Works with the block editor, classic editor and featured images
  • Filterable allow-lists and capability requirements
  • No settings screen required, works out of the box

FAQ
ChangeLog