I need the files field in my panel to prepopulate with the first image it finds using the cover template, but there doesn’t seem to be any documentation on the default property of the files field. Ideally I’d like this population to happen whenever the user uploads an image.
A default value only kicks in at page creation, so it doesn’t make sense for the files field, because you can only upload files after you have created the page.
So way to achieve what you want, would be a hook, in particular a
file.create:after hook: https://getkirby.com/docs/reference/plugins/hooks/file-create-after
Inside your hook, you can then use
$page->update() to update the field value if the uploaded file is an image with template
That works for updating the field value, but what i’d really like is for the cover in the panel to be set as soon as an image is uploaded.
edit: actually, that’s not very necessary lol. nvm
Somehow I’m missing the difference between these two alternatives?
ah, then it didn’t work. nevermind.
what i wanted didn’t end up being necessary, anyway.