Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting Thumbnails from media/cache #1012

Closed
p-carrillo opened this issue Nov 23, 2017 · 1 comment
Closed

Deleting Thumbnails from media/cache #1012

p-carrillo opened this issue Nov 23, 2017 · 1 comment

Comments

@p-carrillo
Copy link

Q A
Bug Report? no
Feature Request? no
BC Break Report? no
RFC? no
Imagine Bundle Version 1.9.1

Hi,

I have the bundle installed and configured with Sonata Admin Bundle, when I try to remove an Image, the image is properly deleted from the folder but not the thumbnail stored in media/cache.

this is my 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 }

Any Idea why or how to delete this thumbnails?

Thaks in advance.

@p-carrillo
Copy link
Author

Workmate managed to solve it using Liip cachemanager. Here is the code:

Service:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant