[Image] Add Image component - #3765
Open
seb-jean wants to merge 1 commit into
Open
Conversation
seb-jean
force-pushed
the
feat/image-component
branch
from
August 11, 2026 19:25
e9afd28 to
7748f93
Compare
seb-jean
force-pushed
the
feat/image-component
branch
from
August 11, 2026 19:28
7748f93 to
2321cf0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a new
symfony/ux-imagepackage providing Twig components for rendering<img>,<picture>and<source>HTML elements.Components
<twig:ux:img>: renders an<img>element (runtime renderer, void element)<twig:ux:picture>: renders a<picture>wrapper (template-based, accepts children)<twig:ux:source>: renders a<source>element (runtime renderer, void element)Twig functions
ux_img(): programmatic alternative to the componentux_picture(): programmatic alternative with sources arraySupported attributes
All standard HTML attributes:
src,alt,srcset,sizes,width,height,loading,decoding,fetchpriority,crossorigin,referrerpolicy,ismap,usemap. Extra attributes (class,id,data-*, …) are passed through.srcsetandsizesaccept both strings and PHP arrays for readability.Validation
The components validate attributes against the HTML specification at render time:
altis always required (empty string allowed for decorative images)srcorsrcsetmust be providedsrcsetmust not mix width (w) and density (x) descriptorssrcsetmust not contain duplicate descriptorssizesrequires allsrcsetcandidates to usewdescriptorssizes="auto"(or"auto, <fallback>") requiresloading="lazy"loading,decoding,fetchpriority,crossorigin,referrerpolicy) are validated<source>does not acceptsrcExample