ImageBundle icon indicating copy to clipboard operation
ImageBundle copied to clipboard

Caching across Controller and Twig

Open jakenoble opened this issue 10 years ago • 2 comments

I have been having some major issues with the cache. Doing the following in a Controller

$imageFormatter->open($path)->zoomCrop(100,100)->jpeg()

Produces a .jpg file. But doing this in Twig produces a completely different file with the .jpeg extension

{{ web_image(path).zoomCrop(100, 100) }}

I would have thought both of these calls are the same, so any subsequent calls would not produce the same file again. But it does run the resize and crop again.

How can I stop this from happening? So that the cache is used and is useful across both Twig and the Controller?

jakenoble avatar Feb 20 '15 13:02 jakenoble

Hm, we should track this to understand what is really different If the hash is different, the operation applied may look different to the Image handler, you could try dumping the array that is hashed by the Gregwar/Image class in both cases

Gregwar avatar Feb 20 '15 23:02 Gregwar

I looked at the array and I think the issue comes from the path. Using image or web_image produces two different paths, rightly, and therefore two different hashes and two different images. This is fine and would be hard to engineer around as one path is absolute and the other relative.

But that doesn't explain why sometimes it produced a .jpg file and other times a .jpeg file?

jakenoble avatar Feb 23 '15 09:02 jakenoble