Reviewed & tested by the community
Project:
Svg Image
Version:
3.x-dev
Component:
Code
Priority:
Major
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
11 Aug 2021 at 16:00 UTC
Updated:
24 Mar 2026 at 10:18 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
mrshowermanHere's a first patch.
Comment #3
mrshowermanComment #4
mrshowermanComment #5
qazema commentedWe applied the patch on a Drupal 9.4.5 installation and it works well.
Comment #7
FalkNisius commentedSorry, that I react late. Thanks for the work.
My team runs in the issue with missing width and height, and the approach should be changed.
The actual code prefers the width and height attribute from the svg-tag. Most exporters write 100% to that attributes, and it results to a width and height of 100 pixel, because the code strips the % sign.
The viewBox attribute is more usual and should be preferred if it exists.
The code depends on the letter case of the attributes, that is not always given, that viewBox is written as camel case.
The first two values of viewBox should not be ignored, they can have positive and negative values. The values in the viewBox can be float. We have to build a difference between the right and left corner values. At least the absolute values of the difference should be used.
Comment #8
bronismateusz commentedI tested patch #4 and it only works when the image style uses crop or scale and crop. Then the values for width and height are actually passed on correctly. If these filters are not applied, then these attributes are missing, for the img field.
In addition, I also see that the rotate or desaturate filter does not work either.
Comment #9
bronismateusz commentedI have prepared a patch that fixes the addition of width and height attributes for the other filters in the image style.
Comment #12
mrshowermanLeft a few notes on the MR.
Comment #13
jennypanighetti commentedMR#32 as a patch worked great for me!
Comment #14
firewaller commentedThe MR#32 changes work for us as well!