I thought it would be clever to add a files section to a file blueprint in order to be able to provide alternative files (in this case for a video). That way I could upload a main file (e.g. a WebM video) and provide one or multiple fallbacks (e. g. an MP4 video)—on a per-file basis.
When I set this up and don’t provide the parent option, I see an error when trying to upload a file:
No route found for path: "pages/projects+test-123/files/video.mp4/files" and request method: "POST"
When I look at the route it looks like Kirby is treating the file like a page and tries to access its files.
So I tried to set the section parent to the main file’s parent by adding parent: file.parent to the blueprint. Now, instead of the files section, I see an error in the panel (I replaced the private path with xxx):
Kirby\Cms\File::is(): Argument #1 ($file) must be of type Kirby\Cms\File, Kirby\Cms\Page given, called in xxx/kirby/config/sections/files.php on line 115.
Therefore I tried it with parent: page.parent and get this error instead:
The parent for the query "page.parent" cannot be found in the section "alternativeFiles"
Should this be possible? Am I doing something wrong? I think it would be a neat solution for the fallback / alternative file type problem.
Actually… now I noticed that I would of course see the alternative files of all files that were uploaded in the same directory, which is not really a gain. Probably I wont’t get around creating a subfolder for each file that can contain alternative files as well.
I would have preferred the files section so that the files could have been managed (i. e. deleted) in place. Now it’s only possible to delete a file if you select it in the field and click on it afterwards. Still works though.