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

时间:2017-11-23 11:15:14

标签: php symfony sonata-admin liipimaginebundle

我安装了捆绑包并使用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 :(得分: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}  

腓:

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