svgSanitizer
Creator: Hugo Peek (suikerzout)
Updated by: Hugo Peek (hugopeek)
Screenshots
About svgSanitizer
A MODX extra for parsing SVG files inline. The file is cleaned first, to make sure there's no malicious javascripts or external links inside.Uses the following sanitizer: https://github.com/darylldoyle/svg-sanitizer/
For additional information and bug reports, see Github.
Why?Because SVGs are a perfect way for delivering sharp and scalable graphics on your site. And serving them inline makes them even more versatile! You can change the colors of individual paths, let the SVG adapt to its parent's fill color or animate the contents with JS.An added bonus for including SVGs with the svgSanitize snippet, is that you can actually use MODX syntax inside your SVGs. Create multilanguage SVGs by using lexicon strings as text, or use them in getResources templates with unique pagetitles or TV data... Endless possibilities.Have fun!
Information
Released
April 28, 2023
Supported Database
MySQL
License
MIT
Supported Versions
2.3 - Current
Downloads
1,159
Instructions
A MODX extra for parsing SVG files inline. The file is cleaned first, to make sure there's no malicious javascripts or external links inside.
Uses the following sanitizer: https://github.com/darylldoyle/svg-sanitizer/
Inline usage
All you need to do to get started, is place your SVGs in a folder somewhere inside your project and reference the file path in the svgSanitize snippet call:
Create SVG sprite
In addition to cleaning your SVG, you can choose to output the result as a symbol, for use in an SVG sprite:
...
Will result in something like:
Yay, you cared about accessibility
...
...
Include this SVG somewhere in your HTML and then reference the symbols in your content like this:
New in 1.1.0-pl
svgSanitizer 1.1.0
Released on February 24, 2023
- Better error handling
- Better detection of changes in file, to force a cache refresh
- Remove aria-labelledby attribute (with possibly empty ID)
- Add ability to attach classes to SVG tag
- Add options to strip fill / stroke tags from SVG
- Update svg-sanitize to 0.15.4