Skip to content

Strip srcset from archived picture img#341

Open
sentience wants to merge 2 commits intochromaui:mainfrom
sentience:codex/fix-playwright-picture-img-srcset
Open

Strip srcset from archived picture img#341
sentience wants to merge 2 commits intochromaui:mainfrom
sentience:codex/fix-playwright-picture-img-srcset

Conversation

@sentience
Copy link
Copy Markdown

@sentience sentience commented May 5, 2026

Fixes #340.

What Changed

Stripping of responsive srcset and sizes needs to apply not just to <source> tags, but to the <img> element.

Here's a sample (valid) responsive HTML image:

<picture>
  <source
    type="image/webp"
    srcset="/img/VqWA1gUDgT-163.webp 163w, /img/VqWA1gUDgT-271.webp 271w"
    sizes="(min-width: 1280px) 271px, 163px"
  >
  <img
    src="/img/VqWA1gUDgT-163.jpeg"
    srcset="/img/VqWA1gUDgT-163.jpeg 163w, /img/VqWA1gUDgT-271.jpeg 271w"
    sizes="(min-width: 1280px) 271px, 163px"
    alt="Ahnitol crabs"
  >
</picture>

Here's the (incorrect) captured DOM before this fix:

{
  "tagName": "img",
  "attributes": {
    "src": "/img/VqWA1gUDgT-271.webp",
    "alt": "Ahnitol crabs",
    "srcset": "http://localhost:8080/img/VqWA1gUDgT-163.jpeg 163w, http://localhost:8080/img/VqWA1gUDgT-271.jpeg 271w",
    "sizes": "(min-width: 1280px) 271px, 163px"
  }
}

And here's the (correct) captured DOM after this fix:

{
  "tagName": "img",
  "attributes": {
    "src": "/img/VqWA1gUDgT-271.webp",
    "alt": "Ahnitol crabs"
  }
}

How to test

Unit tests updated herein. If you really need me to provide a sample Playwright project to confirm the issue and the fix, let me know.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 5, 2026

🦋 Changeset detected

Latest commit: 0602efe

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@chromatic-com/playwright Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

@chromatic-com/playwright archive contains stale img[srcset] for responsive images

1 participant