Problem/Motivation
Some components initialize its own attributes, no ways to pass the `attributes`. Eg. card
Other inherits parent component/container `attributes`, e.g. Image component:
When image component is used inside a component or a container with `attributes`, the `attributes` being consumed by the image component due to components/image/image.twig:35
{% set image_attributes = fallback_attributes.merge(attributes ?: []) %}
Steps to reproduce
- Have a parent component or template (e.g. paragraph) that contains `attributes`.
- Include an image component.
- Image component uses the `attributes` not meant for it.
Proposed resolution
Standardize all components implementation, use a unique `COMPONENT_attributes`, which can be passed `attributes` as needed.
Remaining tasks
-
User interface changes
-
API changes
-
Data model changes
Comments
Comment #3
ckngThese are initial fixes. Note that haven't gone through all the components yet.
Unsure items, not used or will break backward compatibility, ie. subtheme needs to be updated:
Comment #4
ckngComment #5
ckngBackward incompatible tracking for subtheme:
- templates/field/image.html.twig
Comment #6
ckng- restored image functionality when passing src directly
Comment #7
pdureau commentedIf you do that, you will have both
COMPONENT_attributesandattributesin your template, which is confusing and may lead to other issues.It seems you have another problem to fix, probably in the way your are calling the components.
For example (not tested, just a proposal), instead of doing that:
You may need to use the
onlykeyword:Comment #10
doxigo commentedThanks a lot ckng, merged.
Pierre I'll check and see what we can do.