Skip to content

SVG Upload

Alex de Borba edited this page Jun 21, 2026 · 1 revision

SVG Upload

Aegis provides secure SVG file upload support with configurable sanitization options. This feature allows administrators to upload SVG files to the WordPress media library while protecting against security vulnerabilities.

Overview

SVG files are a common vector image format used for logos, icons, and illustrations. However, SVG files can contain embedded scripts and other potentially malicious content. Aegis uses the enshrined/svg-sanitize library to strip dangerous content before saving uploaded SVGs.

Configuration

SVG upload settings are managed through the Aegis settings panel. The following options are available:

Setting Default Description
SVG Upload Enabled Allow SVG files to be uploaded to the media library.
Strip Colors Disabled Remove color attributes from SVG elements on upload.
Strip Dimensions Disabled Remove width and height attributes from SVG root element.
Strip Styles Disabled Remove inline style attributes from SVG elements.

Security

All uploaded SVG files are sanitized using the enshrined/svg-sanitize library which:

  • Removes potentially malicious <script> elements.
  • Strips onclick, onload, and other event handler attributes.
  • Removes <foreignObject> elements.
  • Strips references to external resources.
  • Removes data URIs that could contain embedded scripts.

Settings Access

SVG settings are stored in the aegis_settings WordPress option and managed by the Aegis\Admin\SettingsRepository class. When the Aegis plugin is active, the settings interface is provided by the plugin. The theme provides a backward-compatible facade that delegates to the plugin settings when available.

Next Steps

Clone this wiki locally