Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Can we get some instructions on how to install this on Drupal 8? There are instructions for Drupal 7 but nothing for Drupal 8! It's really not the same I dont think because,
- Getting the enshrined svg sanitizer library from git and manually putting it in the library folder then installing the module through composer did not work (I didnt see any settings for content or media types etc)
- Installing the library through Composer doesnt work cause it conflicts with the module so you cant install both that way, it's one or the other
- Also didnt work by installing the module only. Where are the settings?!?!
Comments
Comment #2
Dru Pal CreditAttribution: Dru Pal commentedComment #3
Dru Pal CreditAttribution: Dru Pal commentedComment #4
larowlanComment #5
larowlanThe module provides a formatter - https://git.drupalcode.org/project/svg_sanitizer/blob/8.x-1.x/src/Plugin...
The formatter is available for any file or svg_icon field.
Installation should be achieved by
composer require drupal/svg_sanitizer
Comment #6
larowlanI also added these instructions to the project page
Comment #7
Dru Pal CreditAttribution: Dru Pal commentedThanks for your reply and instructions but it still doesnt explain how to configure the module in Drupal 8. And I watched your youtube video which was helpful but I do not see any Format SVG type under "Manage Display". For example if I go to Home >> Administration >> Structure >> Media types (which is in Drupal Core by Default), I dont see an SVG formatter under Manage Display, I have installed 8.x-1.0-alpha1 and it's enabled. Are there no configuration or permission settings? It does not show any link under extend.
Comment #8
larowlanWhat fields are on the media types?
It only works with file and svg_icon fields. I.e it doesn't work with image fields.
Comment #9
Dru Pal CreditAttribution: Dru Pal commentedOK that explains it now. But on the home page of this module it says "It also makes an SVG Sanitizer field formatter available for image and file fields". That's some pretty important change/missing info that should be clearly in the instructions.
Comment #10
larowlanAh, thanks - I only worked on the D8 port so haven't really looked closely at the project page.
I clarified that images is D7 only, and added a note about SVG Icon in D8.
In terms of working with Media, we typically add a new media-type called SVG with a file field (or SVG icon) so that we can lock down the permissions.
Even with this module, we don't like giving non-admins access to upload SVG, so having a separate media-type gives us the finer-grained permissions.
Comment #11
larowlanAdding issue Credit for @Dru Pal who helped improve module documentation
Comment #12
larowlanComment #13
Dru Pal CreditAttribution: Dru Pal commentedThanks a lot. Hopefully more people learn to use this necessary module when including SVGs on their site.