Follow-up to #2260061-297: Responsive image module does not support sizes/picture polyfill 2.2
- 'attributes' stays in the $variables array that gets passed to responsive-image.html.twig, and is thus *also* printed as {{attributes}} on the picture tag ? I'd tend to agree with @attiks in #298.2 that we don't necessarily need to support attributes on the picture tag, but even if we do, it can't just be the same ones the than those of the img ;-)
Comments
Comment #1
attiks CreditAttribution: attiks commentedSome relevant content from the other issue
#2260061-297: Responsive image module does not support sizes/picture polyfill 2.2 and following
As far as I know
element can use global attributes, though probably not used very often. Is anything being put there by default? It is certainly conceivable to add a class to even if you aren't styling
itself. (passing no judgement as to whether that is recommended)
All attributes go to the img tag, adding anything to picture has no real value since most browsers will simply ignore it. I think class and id are exceptions, but maybe we should allow it, the big question is then: how to differentiate between attributes for the picture tag and those for the img tag? And is this something that can be done in a follow up issue?
Comment #2
Wim LeersThis is still extremely confusing at the moment. We should totally fix this. And test it.
Comment #5
RainbowArrayAs far as I understand, the picture element really just acts as a wrapper to help with source selection for an img element. I don't think you'd want to apply attributes to the picture element itself. If I want to assign a width on a parent to the img element, I'll add a div wrapper for that. Doing so on a picture element seems problematic.
Comment #17
Mortarion CreditAttribution: Mortarion commentedCurrently and only speaking for Drupal 9.4.8, the `image_loading_settings` are copied to the `item_attributes['loading']`, which are then made available to the attributes of the `responsive_image` template.
But this leads to invalid markup since the `loading` attribute is not allowed inside of an picture element.