Data Liberation: Negotiate browser image formats when downloading media - #4674
Merged
chubes4 merged 1 commit intoAug 26, 2026
Merged
Conversation
The media downloader fetched with no Accept header, so format-negotiating CDNs (Wix, Squarespace, Cloudinary f_auto, imgix auto=format, Photon) returned the legacy/original encoding. On a small Wix store the retina variants came back as 1-7 MB PNGs instead of the ~10 KB AVIFs a visitor's browser receives, the portable media set filled its 160 MiB budget, and the artifact export failed against the 192 MiB compiler limit. Send Chromium's image Accept header and name the downloaded file by the negotiated content type when it differs from the URL extension, so an AVIF body is not stored as `.png`. Same-format aliases (`.jpeg`/`.jpg`, `.tif`/`.tiff`) keep the URL extension. On the same site the export now completes at 128 MB, with 162 AVIF assets in the generated theme instead of 82 multi-megabyte PNGs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
Note on CI: the red "Unit Tests" job is inherited from the base branch. PR #3952's own build (buildkite 21303) fails the same job, and the failing suites are all in |
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.
What
The Data Liberation media downloader now sends the same image
Acceptheader a browser sends, and names the saved file by the content type that actually arrives when it differs from the URL extension.Why
downloadMediafetched with noAcceptheader. CDNs that negotiate image formats (Wix, Squarespace, Cloudinaryf_auto, imgixauto=format, Photon) then return the legacy or original encoding.On a 28-page Wix store, retina variants came back as 1 to 7 MB PNGs instead of the ~10 KB AVIFs a visitor gets. The portable media set filled its 160 MiB budget and the export failed with "Portable capture exceeds compiler limits" after a three-minute capture.
Same URL, measured with curl: no
Accept→image/png, 1,409,778 bytes. BrowserAccept→image/avif, 8,759 bytes.With this change the same capture exports at 128 MB and the generated theme carries 162 AVIF assets.
How to test
cd packages/data-liberation-agent && npx vitest run src/lib/media-fetchstudio create --from https://<a-wix-site>and checkcapture-receipt.json→portableMedia.selected_bytesand thewebsite/media/*.aviffiles.Bundles were rebuilt from this source (
npm run buildin the package leaves the tree clean).Part of the
studio create --fromwork in #3952.AI assistance: Claude Code (Claude Fable 5) traced the size failure to the missing
Acceptheader and drafted the change. Aagam Shah directed the work and is responsible for it.🤖 Generated with Claude Code