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
Supporting organizations: 

Project information

Releases