- First commit to issue fork.
- 🇳🇱Netherlands watergate
The patch provided in #3126330-3: Apply image style dimensions with HTML attributes → didn't apply anymore to the latest version, so I've updated the code and created a merge request.
- Status changed to RTBC
about 1 year ago 11:49am 2 November 2023 - 🇫🇷France GaëlG Lille, France
I tested and confirm that the merge request successfully adds width and height HTML attributes to img tags with an SVG rendered using the default image formatter with an image style applied.
Same as GaëlG.
MR from #5 tested and confirmed to work.
Waiting for this to be available in the next stable release.- 🇳🇱Netherlands watergate
@clemorphy, thanks for testing. You can download a plain diff from the merge request. See the plain diff link under the issue fork list at the top of this page (left beside the green "MR !25 mergeable"). For additional information, see https://www.drupal.org/docs/develop/git/using-gitlab-to-contribute-to-dr... →
- 🇮🇳India saurabhpandit26 Mumbai
Re-rolling the patch for latest version.
- 🇫🇷France GaëlG Lille, France
I made a new branch which also contains the fix from 📌 Formatters shouldn't repeat core code Needs review , because I needed both fixes:
https://git.drupalcode.org/issue/svg_image-3126330/-/commits/3257729-312...The code for this issue changes quite a lot when 📌 Formatters shouldn't repeat core code Needs review is applied.
On this branch, I also added support for responsive images. I guess my branch could become the one for an up-to-date merge request if 📌 Formatters shouldn't repeat core code Needs review lands before this one.
I manually tested locally and it seems to work well on my use case but I did not carefully tested all the possible usages.
-
mably →
committed 73f61766 on 3.x authored by
watergate →
Resolve #3126330 "Apply image style"
-
mably →
committed 73f61766 on 3.x authored by
watergate →
- 🇫🇷France mably
Looks like I have merged it too quickly.
Styling doesn't seem to work on my side.
$dimensions = [ 'width' => $item->width, 'height' => $item->height, ];
width
andheight
seem to be alwaysNULL
here...@gaëlg an idea?
- 🇫🇷France mably
@gaëlg this code seems to work, could we switch to it?
if (empty($attributes['width']) && empty($attributes['height']) && isset($imageStyle)) { // Determine the dimensions of the styled image. $dimensions = svg_image_get_image_file_dimensions($file); $imageStyle->transformDimensions($dimensions, $file->getFileUri()); $attributes['width'] = $dimensions['width']; $attributes['height'] = $dimensions['height']; }
Or may be the MR code is trying to do something different that I am missing?
- Merge request !40Issue #3126330 by @mably: Apply image style dimensions with HTML attributes → (Merged) created by mably
- 🇫🇷France GaëlG Lille, France
MR40 looks good to me. If it works, it should be committed.
Automatically closed - issue fixed for 2 weeks with no activity.