Repository navigation
Add a format_extension resolver configuration - #1675
Merged
dbu merged 2 commits intoNov 14, 2026
Merged
Conversation
The FormatExtensionResolver could only be used by declaring it as a
service by hand. A new FormatExtensionResolverFactory makes it a
regular resolver configuration, decorating another configured resolver:
liip_imagine:
resolvers:
format_extension:
format_extension:
resolver: default
Document it on the resolver page and in the "WebP for all" section,
where the cached images otherwise keep the extension of the source.
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.
As discussed in #1619 (comment), this makes the
FormatExtensionResolver(#1300) a simple configuration instead of a custom service:FormatExtensionResolverFactorywith a single requiredresolveroption, the name of the configured resolver to decorate. Thedefaultresolver always works, since the bundle adds it when it is not configured.I went with a factory rather than a built-in resolver named
format_extension, because the current docs tell users to declare a tagged service under exactly that name, which would clash.One thing I noticed and documented as a caution rather than changing here: combined with
webp.generateon a filter set with a format other thanwebp, the WebP variantimage.png.webpis stored asimage.png.jpeg(forformat: jpeg), since the resolver replaces the last extension with the format of the filter set. I checked this directly against the resolver. Withformat: webpor no format, the variant keeps its name. Happy to look at it in a follow-up if you think it's worth it, though with your preference for the srcset approach it may not be.Tests: unit tests for the factory, plus a functional test that filters
images/cats.jpegthrough a filter set withformat: pngand checks it is stored ascats.png. The new tests fail without the factory registered. The full suite is green on PHP 8.5.