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
Krleza opened this issue Nov 23, 2017 · 1 comment
Closed

Deleting Thumbnails from media/cache #1012

Krleza opened this issue Nov 23, 2017 · 1 comment

Comments

@Krleza
Copy link

@Krleza Krleza commented Nov 23, 2017

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.

@Krleza

This comment has been minimized.

Copy link
Author

@Krleza Krleza commented Nov 30, 2017

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());
    }
 }
@Krleza Krleza closed this Nov 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.