Hi kirby lovers,
I have a strange issue regarding the thumb function inside a hook.
When I upload an single file it works great, but when I upload multiple
files, the url to the thumb gets wrong, and it reverts the already uploaded thumb files
to “7575" instead of "100100”. The field “filer” is the “builder field” by https://github.com/TimOetting/kirby-builder
kirby()->hook('panel.file.upload', function($file) {
$page = $file->page();
if ($page->intendedTemplate() === 'page') {
$filer = $page->filer();
$img = thumb($file, array('width' => 100, 'height' => 100))->url();
if ($filer) {
$files = $filer->yaml();
$files[] = [
'name' => (string)$file->name(),
'uri' => (string)$file->uri(),
'url' => (string)$file->url(),
'ext' => (string)$file->extension(),
'thumber' => $img,
'_fieldset' => 'filer'
];
$page->update([ 'filer' => yaml::encode($files) ]);
}
}
});