Webp and animated media - #68
Merged
Merged
Conversation
It should not affect single frame files, and will process multi-frame media.
But adding it to this code change for cleanup.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for resizing WebP assets and preserves animated frames when processing animated image formats during on-demand object generation.
Changes:
- Extend size-suffix URL matching and original-path reconstruction to include
.webp. - Update
sharpinvocation to enable animated frame processing ({ animated: true }). - Add a unit test covering WebP original lookup and resize flow.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/getOrCreateObject/resizeAndSave.js |
Enables animated frame handling in sharp and removes the unused getOriginalS3Key export. |
src/getOrCreateObject/getOrCreateObject.js |
Adds .webp to size-suffix detection and original-path reconstruction logic. |
src/getOrCreateObject/getOrCreateObject.test.js |
Adds a WebP fixture/mocked object and a test covering WebP resize behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Large or animated images can exceed sharp's pixel limit, leading to resize failures. This change catches the `exceeds pixel limit` error and serves the original, unscaled image instead of failing the request. Any other sharp errors are still rethrown. Comprehensive unit tests verify this graceful degradation.
bfenster
approved these changes
Aug 6, 2026
| } | ||
|
|
||
| // This image can't be resized, so serve the original unscaled for this request. | ||
| // Nothing is saved to S3, because there is no resized image to save. |
This was referenced Aug 7, 2026
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.
Adds support for resizing animated media in addition to single images. Also adds support for resizing WebP assets.
This change essentially enables the animation processor for all resizes. Testing locally and on the dev stack indicates that still frame processing time is not affected by leaving the animation flag on.
It also adds a try/catch block to detect animated media that exceeds the maximum sharp processing limit. More information is available in the repo wiki, including limitations on what sizes can be processed and what sizes are likely to fail because they are too big.
I've run this in a dev instance of the lambda stack (wordpress-protected-s3-dev in bu-cc nonprod) with a buwp-local container front end and testing shows it to be robust. All unit tests are passing.
Addresses #66 and #67
Merging activates the deploy pipeline and will deploy to prod.
Changes:
.webp.sharpinvocation to enable animated frame processing ({ animated: true }).