EARTHLOOMGuides   Apps

How to safely upload SVG files to WordPress and see what gets removed

WordPress blocks SVG uploads by default because the format can contain executable code. Many sites install a sanitizer that silently strips risky parts, leaving owners unaware of what was removed. By using a preflight tool you keep the visual benefits of SVG while maintaining full visibility of any changes before the file goes live.

Why this is harder than it looks

Site owners often need scalable graphics for logos or icons, but uploading an SVG without inspection can expose the site to XSS attacks, malicious URLs, or hidden scripts. Existing plugins either block all SVGs or clean them silently, so administrators cannot audit what was stripped. This lack of transparency makes compliance and security audits difficult, especially for agencies handling many client sites.

Step by step

  1. Install the SVG Gate plugin. From the WordPress dashboard go to Plugins → Add New, click “Upload Plugin,” select the SVG Gate zip file, then press “Install Now.” After installation, click “Activate” to make the plugin operational on your site.
  2. Activate and configure preflight settings. Navigate to Settings → SVG Gate. Choose “Clean mode” to automatically strip disallowed elements, or “Block mode” to reject the upload entirely. Set the maximum file size (e.g., 500 KB) and depth limit (e.g., 10 levels) to avoid oversized or deeply nested SVGs.
  3. Define role‑based upload permissions. In the same settings page, scroll to “User Roles.” Check the boxes for Administrator and Editor (or any custom role) that should be allowed to upload SVGs. Unchecked roles will see the upload option disabled, preventing accidental unsafe uploads.
  4. Upload an SVG via the Media Library. Go to Media → Add New, drag the SVG file into the upload area, or click “Select Files.” The plugin runs a preflight scan instantly. If the file passes, it appears in the library; if not, an error message lists the blocked elements.
  5. Review the preflight report column. Return to Media → Library and switch to List View. A new column labeled “SVG Report” shows a summary for each SVG: number of scripts removed, external URLs blocked, and any oversized elements. Click the report to expand a detailed table of every element that was stripped or flagged.
  6. Re‑upload a cleaned version if needed. If the report indicates critical graphics were removed (e.g., a missing <use> reference), edit the original SVG in a vector editor to eliminate the offending code, then upload again. The plugin will re‑run the scan and confirm the file is now clean before accepting it.

Common mistakes

Where SVG Gate fits in

SVG Gate preflights every SVG upload, scanning for scripts, event handlers, external references, oversized files and more. It shows a visible report in the Media Library, lets you choose clean or block mode, and restricts uploads by user role, so you always know what was removed before the file is stored.

SVG Gate support and FAQ

FAQ

Does the plugin affect PNG or JPEG uploads?

No. SVG Gate only hooks into the upload process for files with the .svg extension. All other image types are handled by WordPress as usual and remain untouched.

Can I allow specific scripts in an SVG?

The plugin’s clean mode removes all script, event, and JavaScript URLs. If you need to keep a particular script, you must edit the SVG manually after the scan and re‑upload, or switch to block mode and whitelist the file outside WordPress.

How do I export the preflight report for auditing?

In the Media Library list view, click the “Export CSV” button that appears above the SVG Report column. The generated CSV contains each file’s name, size, and a line‑by‑line list of removed elements for compliance records.