V
V
Vasyl Fomin2016-11-15 12:26:54
Images
Vasyl Fomin, 2016-11-15 12:26:54

Using Intervention\Imagecache in Laravel. How to get the path to the image in the cache?

I can’t figure out how to use the package for caching images in Laravel Intervention \ Imagecache.
I do it as in the instructions:

$path = 'Полный путь до картинки';
$img = Image::cache(function($image) use($path) {
   return $image->make($path)->resize(300, 200)->greyscale();
}, 10, true);

If done according to the instructions, then the function returns the image itself to the $img variable (which, of course, I can show like this: return Response::make($img, 200, ['Content-Type' => 'image']); ), but I need to get the path to it in the cache, so that I can display it on the page with the text in the tag.
The cached file itself can be found in the site/storage/framework/cache folder, but they have random names and do not open.
Previously, I thought that the cache works as follows:
1. I give the path to the original image,
2. the package checks if it is in the cache,
3. if it is, it returns the path from the cache,
4. if not, it caches and returns the path from the cache.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2016-11-15
@fomvasss

Make your own image route and return the image itself, as in the example. In any case, the browser will not be able to access the files in the "site/storage/framework/cache" folder directly, a layer is needed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question