azzaze
azzaze

Reputation: 151

Symfony 4 - LiipImagine - How to clear cache?

on symfony 4 I use LiipImagineBundle for the display of my images. But I noticed that there were cache problems. My config is:

# See dos how to configure the bundle: https://symfony.com/doc/current/bundles/LiipImagineBundle/basic-usage.html
liip_imagine:
  # valid drivers options include "gd" or "gmagick" or "imagick"
  driver: "gd"
  filter_sets:
    cache: ~

    # the name of the "filter set"
    avatar_big:
      # adjust the image quality to 75%
      quality: 75

      # list of transformations to apply (the "filters")
      filters:
        # create a thumbnail: set size to 120x90 and use the "outbound" mode
        # to crop the image when the size ratio of the input differs
        thumbnail: { size: [120, 120], mode: outbound }

My images are in :

public\images\avatar\

Is there a way to automatically clear the cache? I saw that there were orders to be made but I wonder if we can automate all that

Upvotes: 3

Views: 5545

Answers (1)

MigMolRod
MigMolRod

Reputation: 759

If you mean to delete the cache images generated by your imagine filters, then LiipImagineBundle adds a command to Symfony console that does that:

php bin/console liip:imagine:cache:remove

Without any parameters, you will delete cache images for all paths and all filters.

You can use parameters to narrow the deletion to whatever filters and paths you want, like this:

php bin/console liip:imagine:cache:remove path1 path2 --filters=thumb1 --filters=thumb2

You have more information and examples here: https://symfony.com/doc/current/bundles/LiipImagineBundle/commands.html#remove-cache

Upvotes: 11

Related Questions