从 liip imagine bundle 中的 media/cache 中删除缩略图

Deleting Thumbnails from media/cache in liip imagine bundle

我使用 Sonata Admin Bundle 安装并配置了捆绑包,当我尝试删除图像时,图像会从文件夹中正确删除,但不会删除存储在 media/cache 中的缩略图。

这是我的 liip_imagine yml:

liip_imagine:

loaders:
    loader_s3_thumbnail:
        stream:
            wrapper: gaufrette://questions_image_fs/

filter_sets:
    question_thumb:
        cache: default
        data_loader: loader_s3_thumbnail
        # list of transformations to apply (the "filters")
        filters:
            thumbnail: { size: [120, 120], mode: outbound }

    provider_thumb:
        cache: default
        data_loader: loader_s3_thumbnail
        # list of transformations to apply (the "filters")
        filters:
            thumbnail: { size: [200, 200], mode: inset }

知道为什么或如何删除这个缩略图吗?

Workmate 使用 Liip cachemanager 设法解决了这个问题。这是代码:

服务:

  question.admin_bundle.event_listener.delete_thumbnails:
    class: QuestionAdminBundle\EventListener\DeleteThumbnails
    arguments: [ "@liip_imagine.cache.manager" ]
    tags:
        - { name: kernel.event_listener, event: vich_uploader.pre_remove, method: postRemove}  

Php:

use Liip\ImagineBundle\Imagine\Cache\CacheManager;
[...]
public function __construct(CacheManager $cacheManager)
{
     Add a comment to this line
     $this->cacheManager = $cacheManager;
}
[...]
public function postRemove(Event $event)
{
    $image = $event->getObject();
    if ($image instanceof Image){
        $this->cacheManager->remove($image->getName());
    }
 }