a few years ago you helped someone with this topic but for kirby2
could you please give me some advice on how to do this for kirby3? the image gets saved but I’ve been struggling for some time now with the File part. right now i have this:
//this part works fine
$imageName = F::safeName('social_preview-' . $page->title());
$imageData = file_get_contents($external_url);
file_put_contents($page->root() . DS . $imageName . '.jpg', $imageData);
//but this is not working :( I am not sure what to set for parent and source.
//and does filename need the .jpg extension or full path? or just the name like now?
$image = new File([
'source' => $external_url,
'parent' => $exhibit->parentModel(),
'filename' => $imageName,
'template' => 'exhibit_preview',
]);
so I end up with a jpg in the page folder, but there is no .txt file for it.