Closed (fixed)
Project:
PhotoSwipe - Responsive JavaScript Modal Image Gallery
Version:
5.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
4 Jul 2022 at 12:49 UTC
Updated:
8 Oct 2026 at 16:05 UTC
Jump to comment: Most recent
Comments
Comment #2
anybodyComment #3
anybodyHappy to review patches / MR's here. Feel free to set this back to active or needs review then.
I'm not sure if photoswipe 4 itself supports SVGs... that should be checked first.
Comment #4
anybodyComment #5
anybodyComment #6
anybodyRating this as minor / edge-case. Let's test this with v5 later.
Comment #7
anybodyComment #8
anybodyComment #9
thomas.frobieterHere is a dirty (CSS) workaround to prevent (end)users from running into this. Otherwise the user will see an error message in the PSWP layer.
Comment #10
grevil commentedComment #11
anybodyComment #12
anybodyComment #14
grevil commentedAlright that should be it. But TBH I am unsure if this currently makes sense, as the js photoswipe library doesn't provide a white background for svgs, So on many svgs you can't really see anything.
@anybody I guess we need to create a photoswipe js issue and fix it there?
Comment #15
thomas.frobieterThe issue only stands out because you're testing with SVG files that, in all likelihood, will never be used in Photoswipe as-is. It's just as likely that a transparent background is what's needed.
In my opinion, this isn't a relevant issue.
Comment #16
anybodyThanks @grevil great work. I added a little, but important, comment and think this is good to go. Regarding the background let's wait for user feedback and reports.
Good enough to be merged IMHO. Started merge train.
Comment #17
grevil commentedOk two final things we need to do before we can publish this:
Provide a way to change the background for the photoswipe image view. To do so we need to conditionally set css like:
(e.g. for white background)
The background opacity is already configurable in the photoswipe global settings. I'd say we provide a background setting on global and formatter level (if set formatter level overrides global). As for "normal" photoswipe formatters we usually want to have the "normal" dark background, but for the svg formatter we want a white background. Making the setting setable on both levels gives us maximum flexibility.
Furthermore I am against putting the svg sanitizator in the main module composer dependency. The sanitization library already ships with svg_image, but not with svg_image_field. "svg_image_field" itself has some basic upload validation, but I would still like to sanitize the ouput with the same controller.
Maybe we should recommend the library in the composer.json and then add a warning if it isn't installed?
Comment #18
grevil commented@anybody nono, stopped the merge train.
Comment #19
grevil commentedWe should at least fix the composer dependency. Having a dependency on a library, the module usually doesn't need should be fixed here.
For the other point we can add a follow-up.
Comment #20
thomas.frobieterI'd be interested to know what the solution would look like if there were both white images with transparent backgrounds and black images with transparent backgrounds.
As I already mentioned in the chat, this “problem” has existed for a very long time, since it affects transparent PNGs and WEBPs in exactly the same way.
If there isn't an issue open about this, it seems no one has had a problem with it so far.
Comment #21
anybody1.
I already moved it to suggest for that reason
2.
Yes that would make sense in both submodules, not the main module
3. CSS point is nothing we should solve at all or not now, good enough
4. FYI: The svg sanitization controller only gets a route from both submodules so it's not used / available in the main module which is good.
Good enough and ready for merging once (2) is added.
Comment #22
grevil commentedAlright added the requirements hook for svg_image_field submodule. The other already requires "svg_image" which has a hard dependency on that library.
Please do a final review!
Comment #23
anybodyThanks @grevil! RTBC!
Comment #24
anybody