Skip to content

fix: sizes attribute on sourceset#101

Open
tijmenbruggeman wants to merge 8 commits intotinify:masterfrom
wcreateweb:bug/sizes-attr-picture
Open

fix: sizes attribute on sourceset#101
tijmenbruggeman wants to merge 8 commits intotinify:masterfrom
wcreateweb:bug/sizes-attr-picture

Conversation

@tijmenbruggeman
Copy link
Copy Markdown
Collaborator

@tijmenbruggeman tijmenbruggeman commented Apr 7, 2026

When the original image contains sizes, we need to copy these sizes over to the new sources. According to the spec (https://developer.mozilla.org/en-US/docs/Web/HTML/Guides/Responsive_images), the sizes attribute on the original image are also required on the to select the right image.

<img src="test.jpg" srcset="test-360.jpg 360w, test-720.jpg 720w, test.jpg 1200w" sizes="(max-width: 480px) 360px, (max-width: 1024px): 720px, 1200px)" />

should create:

<picture>
  <source 
    type="image/webp" 
    srcset="test-360.webp 360w, test-720.webp 720w, test-1200.webp 1200w" 
    sizes="(max-width: 480px) 360px, (max-width: 1024px) 720px, 1200px" 
  />
  <img 
    src="test.jpg" 
    srcset="test-360.jpg 360w, test-720.jpg 720w, test.jpg 1200w" 
    sizes="(max-width: 480px) 360px, (max-width: 1024px) 720px, 1200px" 
    alt="Description of image"
  />
</picture>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants