首页 文章

在liip imag包中删除媒体/缓存中的缩略图

提问于
浏览
0

我安装了捆绑包并使用Sonata Admin Bundle进行配置,当我尝试删除图像时,图像从文件夹中正确删除,但不是存储在媒体/缓存中的缩略图 .

这是我的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 }

任何想法为什么或如何删除这个缩略图?

1 回答

  • 0

    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());
        }
     }
    

相关问题