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. Web Path Resolver
  • Documentation
  • Book
  • Reference
  • Bundles
  • Cloud

Table of Contents

  • Configuration
  • Usage
    • Configure resolver on a specific Filter Set

Web Path Resolver

Edit this page

Web Path Resolver

This cache resolver (WebPathResolver) enables cache resolution for local, web-path-based setups. This means images will be cached on your local filesystem, within the web path of your Symfony application.

The resulting web path is computed by taking a number of factors into account, including the request context, as provided by the Symfony HTTP kernel.

Tip

The request context is most notably used to determine the HTTP scheme used for the final URL. If you use a proxy to offload TLS traffic decryption and need the resolver to generate secure URLs, you will need to appropriately configure Symfony's trusted proxies. If you utilize embedded controllers in your templates, you must add localhost to your trusted proxies configuration.

Also, the request context is used to determine the port of the resulting URL, should it differ from the standard HTTP/HTTPS (80/443) ports.

Configuration

1
2
3
4
5
6
7
liip_imagine:
    resolvers:
       profile_photos:
          web_path:
            # use %kernel.project_dir%/web for Symfony prior to 4.0.0
            web_root: "%kernel.project_dir%/public"
            cache_prefix: "media/cache"

There are several configuration options available:

  • web_root - must be the absolute path to you application's web root. This is used to determine where to put generated image files, so that your web server can pick them up instead of forwarding the request to Symfony the next time they are requested. The default value is the project directory and public for Symfony >= 4 and web for old Symfony versions. Default value: %kernel.project_dir%/(public|web)
  • cache_prefix - the relative path within the web root where the generated images should be cached. This should be a folder to not clutter your web root with cached images. Default value: /media/cache

Usage

After configuring WebPathResolver, 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: profile_photos

Configure resolver on a specific Filter Set

Alternatively, you can set WebPathResolver 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: profile_photos
            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:
    Code consumes server resources. Blackfire tells you how

    Code consumes server resources. Blackfire tells you how

    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 Chansig, a Symfony contributor

    Thanks Chansig for being a Symfony contributor

    1 commit • 6 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