Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

SVG Sanitizer

Security covered Under active development 705 sites

This module integrates Drupal with the SVG Sanitizer library to safely display SVG files. It provides a field formatter that removes potentially harmful attributes and tags from SVGs before rendering them inline, with options to customize which elements are allowed.

Integrates Drupal with the SVG Sanitizer library https://github.com/darylldoyle/svg-sanitizer.

This module registers the SVG Sanitizer with Drupal's library api module. It also makes an SVG Sanitizer field formatter available for image (D7 only), SVG icon (D8 only) and file fields that will attempt to remove non-whitelisted SVG attributes and tags and display the contents of the SVG file.

Features

  • Adds a custom "SVG Sanitizer" field formatter that will remove non-whitelisted tags and attributes before rendering the SVG inline.
  • Ability to add custom attributes to the list of whitelisted attributes.

Installation steps on Drupal 7:

  1. Ensure that the Libraries API module is enabled.
  2. Download the contents of the svg-sanitizer library located at https://github.com/darylldoyle/svg-sanitizer and place it into your libraries directory. Make sure the directory is named svg_sanitizer.
  3. Enable the svg_sanitizer drupal module.

Demo:

Here is a brief demo, https://www.youtube.com/watch?v=Nb9W9-Ufq0g

Installation steps for Drupal 8

  • composer require "drupal/svg_sanitizer"
  • enable the module as normal
  • configure the sanitizer formatter on the appropriate File or SVG Icon fiels
Drupal 9–11

Ask your assistant about SVG Sanitizer

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
3
Tracked since
Jan 2023
Latest release
2 weeks ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Core PHP Release date
2.0.3 Stable 9–11 Oct 29, 2026
2.0.2 Stable 9–11 Jul 18, 2024
2.0.1 Stable 9–10 Jan 24, 2023