Skip to content

Add a format_extension resolver configuration - #1675

Merged
dbu merged 2 commits into
liip:2.xfrom
Amoifr:feature-1619-format-extension-resolver-factory
Nov 14, 2026
Merged

dbu merged 2 commits into
liip:2.xfrom
Amoifr:feature-1619-format-extension-resolver-factory

Conversation

@Amoifr

@Amoifr Amoifr commented Nov 8, 2026

Copy link
Copy Markdown
Contributor
Q A
Branch? 2.x
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Fixed tickets #1619
License MIT
Doc yes

As discussed in #1619 (comment), this makes the FormatExtensionResolver (#1300) a simple configuration instead of a custom service:

liip_imagine:
    resolvers:
        format_extension:
            format_extension:
                resolver: default
    cache: format_extension
  • A new FormatExtensionResolverFactory with a single required resolver option, the name of the configured resolver to decorate. The default resolver always works, since the bundle adds it when it is not configured.
  • Docs: the resolver page now uses the configuration, and keeps the service definition for decorating a resolver defined as a service. The "WebP for all" section explains that the cached images keep the source extension otherwise, and shows the configuration.

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.generate on a filter set with a format other than webp, the WebP variant image.png.webp is stored as image.png.jpeg (for format: jpeg), since the resolver replaces the last extension with the format of the filter set. I checked this directly against the resolver. With format: webp or 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.jpeg through a filter set with format: png and checks it is stored as cats.png. The new tests fail without the factory registered. The full suite is green on PHP 8.5.

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.

@dbu dbu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@dbu
dbu merged commit abcf5a8 into liip:2.x Nov 14, 2026
12 checks passed
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.

2 participants