Caching external images from URL
Permalink
Hi everyone,
I'm currently working on a custom block, one of his features is to load images which arrives as url from an api (json formatted). Now the problem is I don't have access to this api and it gives me huge images (like 4000x4000). What I wanted to do is to resize and cache this images but I couldn't find any way to do this on the documentation. Since concrete5 has an awesome caching system I wanted to use it, otherwise i will implement my own.
Thanks in advance.
I'm currently working on a custom block, one of his features is to load images which arrives as url from an api (json formatted). Now the problem is I don't have access to this api and it gives me huge images (like 4000x4000). What I wanted to do is to resize and cache this images but I couldn't find any way to do this on the documentation. Since concrete5 has an awesome caching system I wanted to use it, otherwise i will implement my own.
Thanks in advance.
Thank you so much, probably i did not understand it right. I thought it would work with locally store images since everywhere it fetches them from id. I'll try and let you know.
Thank you!
Thank you!
I've tried but still have some issues... here is what i did:
let's assume I have my image url in a variable like $img_url="www.mydomain.it/img.jpg";
Now I instanciate a new Image file like described in the doc:
$im= \Image::open($img_ulr);
from here I'd like to save the thumb (I do want it to be saved in the cache and cleaned when cache is cleaned, but that's not a big problem). the point is I have an ImageInterface as returned from open function, but thumnails works with file objects.
Any hint?
let's assume I have my image url in a variable like $img_url="www.mydomain.it/img.jpg";
Now I instanciate a new Image file like described in the doc:
$im= \Image::open($img_ulr);
from here I'd like to save the thumb (I do want it to be saved in the cache and cleaned when cache is cleaned, but that's not a big problem). the point is I have an ImageInterface as returned from open function, but thumnails works with file objects.
Any hint?
Using the Imagine Image Library to Work with Images
https://documentation.concrete5.org/developers/working-with-files-an...
Working with Image Thumbnails
https://documentation.concrete5.org/developers/working-with-files-an...
Since thumbnail cache gets cleared if the cache is emptied I think you probably just want to resize then save your images...