Skip to content

Fix broken image when srcset is missing width or density indicator#315

Open
benjasper wants to merge 2 commits into
kepano:mainfrom
benjasper:image-srcset-issue
Open

Fix broken image when srcset is missing width or density indicator#315
benjasper wants to merge 2 commits into
kepano:mainfrom
benjasper:image-srcset-issue

Conversation

@benjasper

Copy link
Copy Markdown

I encountered markup like this:

<picture>
    <source media="(max-width: 360px)" srcset="https://img.zeit.de/zeit-magazin/2026/26/ausgezeichnet-gebacken-bild-1/square__360x360__mobile, https://img.zeit.de/zeit-magazin/2026/26/ausgezeichnet-gebacken-bild-1/square__360x360__mobile__scale_2 2x">
    <img class="header-article__media-item" src="https://img.zeit.de/zeit-magazin/2026/26/ausgezeichnet-gebacken-bild-1/super__1000x667" alt="xxx">
</picture>

Which currently results in a broken image like this:

![xxx](https://img.zeit.de/zeit-magazin/2026/26/ausgezeichnet-gebacken-bild-1/square__360x360__mobile,%20https://img.zeit.de/zeit-magazin/2026/26/ausgezeichnet-gebacken-bild-1/square__360x360__mobile__scale_2)

I fixed that by changing the regex matching for sourcesets.
I also consolidated the scattered srcset parsing logic into one utils file.

Let me know if you want me to change something.

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.

1 participant