Cache Image Files from a Remote Source

Hi there,

I am working on functionality for my site to include social media posts from Instagram, YouTube etc. All that works very fine.

I am using the built-in cache functionality to store the data from these external APIs for a short period of time so that I don’t send to many requests to these APIs.

Now I have the question if there is a way to “cache” the Image-Files from these Posts in Kirby, so that the files are requested from my own servers in the Front-End. A nice to have feature would be to use the Kirby way of resizing Images for lazyloading and the <img srcset>-Tag.

I have searched the docs and just found the F::read() functionality to download the File from a remote HTTP(S) Source. However I have no idea where to store the downloaded file.

Finn