- 🇩🇪Germany Anybody Porta Westfalica
@Chi while I understand you point from #3 I think this is truely problematic and not something that should be done in twig.
We just ran into the same issue, where we are rendering an image in a certain image style.width / height are missing, but would be expected to be determined from the image style results.
Another point is the "lazy" attribute introduced in 📌 Apply width and height attributes to allow responsive image tag use loading="lazy" Fixed . I think it's very similar to
$responsive
but not boolean, but lazy / eager.TL;DR:
1. When providing a$style
the width / height should indeed be determined automatically
2. A further parameter for the drupal lazy behavior is neededSee https://git.drupalcode.org/project/drupal/-/commit/f8eb47e
Should we create a separate issue for these points or reopen and solve it here?
- 🇩🇪Germany Anybody Porta Westfalica
Update: As this issue was against 8.x-2.x let's proceed in 🐛 drupal_image() needs #width / #height values for fully working image cache scale, lazy-loading and img attributes RTBC !
- Open on Drupal.org →Core: 9.5.x + Environment: PHP 8.1 & MySQL 8last update
over 1 year ago Not currently mergeable. - @anybody opened merge request.
- 🇷🇺Russia Chi
I think when using image style the width and heights are applied automatically. See template_preprocess_image_style().
- 🇩🇪Germany Anybody Porta Westfalica
@Chi: Well, I thought the same :D But that's not the case. They are only added, if the original size is given. -.-
See core image module for details.I'll provide details in 🐛 drupal_image() needs #width / #height values for fully working image cache scale, lazy-loading and img attributes RTBC .
- 🇩🇪Germany Anybody Porta Westfalica
@Chi: FYI in the follow-up issue we're doing this (more or less) expensive operation only if
$style
parameter is used to achieve what you expected in #8!