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

Resolve Programmatically not generate cache #1512

Open
ziat1988 opened this issue May 3, 2023 · 2 comments
Open

Resolve Programmatically not generate cache #1512

ziat1988 opened this issue May 3, 2023 · 2 comments

Comments

@ziat1988
Copy link

ziat1988 commented May 3, 2023

I want to pre-generate the cache, by doing:

public function yourControllerMethod(CacheManager $imagineCacheManager)
    {
        /** @var string */
        $resolvedPath = $imagineCacheManager->getBrowserPath('/relative/path/to/image.jpg', 'my_thumb');

        // ...
    }

But there are no cache generated in media/cache. I tried the console php bin/console liip:imagine:cache:resolve relative/path/to/image.jpg --filters=my_thumb then it works perfectly.
So is it possible to resolve in the code, controller or service? The reason I want to do this is because I have some heavy task image and I want to pre generate the cache before the client request.

Here is my config:

liip_imagine:
    # valid drivers options include "gd" or "gmagick" or "imagick"
    driver: "gd"
    resolvers:
        default :
            web_path : ~
    filter_sets:
        my_thumb:
            quality: 70
            filters:
                thumbnail: { size: [120, 90], mode: outbound, allow_upscale: true  }
                background: { size: [124, 94], position: center, color: '#000000' }

Thanks

@dbu
Copy link
Member

dbu commented May 11, 2023

if you do the web request as the browser would do it, the cache should also be warmed up. if you want to call the liip imagine services from code, i'd check again what the liip:imagine:cache:resolve command does and try to do mimik the same.

@mikocevar
Copy link

Check

#1512
and
#784

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

3 participants