Skip to content
  • About
    • What is Symfony?
    • Community
    • News
    • Contributing
    • Support
  • Documentation
    • Symfony Docs
    • Symfony Book
    • Screencasts
    • Symfony Bundles
    • Symfony Cloud
    • Training
  • Services
    • Platform.sh for Symfony Best platform to deploy Symfony apps
    • SymfonyInsight Automatic quality checks for your apps
    • Symfony Certification Prove your knowledge and boost your career
    • SensioLabs Professional services to help you with Symfony
    • Blackfire Profile and monitor performance of your apps
  • Other
  • Blog
  • Download
sponsored by SensioLabs
  1. Home
  2. Documentation
  3. Bundles
  4. LiipImagineBundle
  5. FormatExtensionResolver
  • Documentation
  • Book
  • Reference
  • Bundles
  • Cloud

Table of Contents

  • Configuration
  • Usage
    • Usage on a Specific Filter

FormatExtensionResolver

Edit this page

FormatExtensionResolver

The FormatExtensionResolver cannot be used by itself. Instead, it is a "decorator" for another resolver. It adds the ability to set the correct file extension when a filter converted the image format.

Configuration

To use this cache resolver, you must first define the cache resolver it will decorate. In this example, we will use the Web Path Resolver.

Next, we need to define a service for this cache resolver and inject the web path cache resolver service to decorate.

1
2
3
4
5
6
7
8
9
10
# app/config/services.yml

services:
    acme.imagine.cache.format_extension:
        class: Liip\ImagineBundle\Imagine\Cache\Resolver\FormatExtensionResolver
        arguments:
            - "@acme.imagine.cache.resolver.web_path"
            - "@liip_imagine.filter.configuration"
        tags:
            - { name: "liip_imagine.cache.resolver", resolver: "format_extension" }

With this configuration, the format extension resolver will rewrite the extension to match the filter format. For example, you have the source image image.png and you apply filter with format jpg you will get jpeg-image image.jpg.

Usage

After configuring FormatExtensionResolver, you can set it as the default cache resolver for LiipImagineBundle using the following configuration.

1
2
3
4
# app/config/config.yml

liip_imagine:
    cache: format_extension

Usage on a Specific Filter

Alternatively, you can set FormatExtensionResolver as the cache resolver for a specific filter set using the following configuration.

1
2
3
4
5
6
7
8
9
# app/config/config.yml

liip_imagine:
    filter_sets:
        cache: ~
        my_thumb:
            cache: format_extension
            filters:
                # the filter list
This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
TOC
    Version
    We stand with Ukraine.
    Version:
    Put the code quality back at the heart of your project

    Put the code quality back at the heart of your project

    Be trained by SensioLabs experts (2 to 6 day sessions -- French or English).

    Be trained by SensioLabs experts (2 to 6 day sessions -- French or English).

    Symfony footer

    ↓ Our footer now uses the colors of the Ukrainian flag because Symfony stands with the people of Ukraine.

    Avatar of Jacob Dreesen, a Symfony contributor

    Thanks Jacob Dreesen (@jdreesen) for being a Symfony contributor

    50 commits • 385 lines changed

    View all contributors that help us make Symfony

    Become a Symfony contributor

    Be an active part of the community and contribute ideas, code and bug fixes. Both experts and newcomers are welcome.

    Learn how to contribute

    Symfony™ is a trademark of Symfony SAS. All rights reserved.

    • What is Symfony?

      • Symfony at a Glance
      • Symfony Components
      • Case Studies
      • Symfony Releases
      • Security Policy
      • Logo & Screenshots
      • Trademark & Licenses
      • symfony1 Legacy
    • Learn Symfony

      • Symfony Docs
      • Symfony Book
      • Reference
      • Bundles
      • Best Practices
      • Training
      • eLearning Platform
      • Certification
    • Screencasts

      • Learn Symfony
      • Learn PHP
      • Learn JavaScript
      • Learn Drupal
      • Learn RESTful APIs
    • Community

      • SymfonyConnect
      • Support
      • How to be Involved
      • Code of Conduct
      • Events & Meetups
      • Projects using Symfony
      • Downloads Stats
      • Contributors
      • Backers
    • Blog

      • Events & Meetups
      • A week of symfony
      • Case studies
      • Cloud
      • Community
      • Conferences
      • Diversity
      • Documentation
      • Living on the edge
      • Releases
      • Security Advisories
      • SymfonyInsight
      • Twig
      • SensioLabs
    • Services

      • SensioLabs services
      • Train developers
      • Manage your project quality
      • Improve your project performance
      • Host Symfony projects

      Deployed on

    Follow Symfony

    Search by Meilisearch