I’m stuck and it’s probably super easy but I just can’t wrap my head around the files in blueprints.
I have a meta section in my blueprints with a cover image and a meta image. For each of them the user should just upload a single image, for example the cover image:
coverImage:
type: files
headline: Cover Image
in Kirby2 I was able to now simple retreive exactly this image by it’s name “coverImage”:
$site->files()->metaImage()
But when I look at the content file the “coverImage” is empty and I’m not able to retreive the image.
Neither through the documentation nor through the examples I was able to solve this. I think the blueprints and especially the files and the nesting of templates in blueprints etc. needs some work to be easier to grasp.
Alright - will try this now. I was just looking at the docs again. I think the confusing part is that there is no mention of templates in the blueprints section but an extra section for templates - I get the difference between templates and blueprint but there is no prominent mention of blueprint templates and how the work and relate to each other.
One last question: I’m now able to retreive the image but I’m not able to upload it in the panel, just selecting one that I uploaded previously - is there a way to combine both? I don’t want to force the user to upload images first and then select them.
The documentation really needs some work: no mention of an “upload section”. If I move the metaImage and make a section out of it I can upload it again but the image won’t get saved in the txt, right? So manual editing is tricky and there needs to be a meta file for the image in order to identify that the image is meant to be a meta image in this case.
Whoeever designed it that way did’t have the user in mind… upload an image identify it by it’s name, save that name in the txt. What was the intention to design it that way so that I can’t upload a file if the file is a fields instead of an section, maybe it’s me but I can’t see any benefits?
In Kirby 2 we had no way of separating different file types into different categories and assign different file blueprints for different meta data. For example, a PDF file would need different metadata than an image file. Also, you can now upload images for a gallery and separate them from other images you want to use for other purposes.
Instead of using different upload sections, you can also have a single general upload section where you upload everything, and then use files fields to select one or more files from the ones that have already been uploaded.
Also, a files field gives you extensive possibilities to filter images, even from all over the site. Adding an add button to such a field would make things very complex. Where should a new image be uploaded in that case? I’m not saying it would be impossible, but would then require an extra upload form where all that information goes into before the file could be stored. Or you would have to define in the blueprint what to do with that file.
I’d also love the option to upload files or create pages from a files/pages field and you can create a custom field with these options.
Totally understandable… but that way the possibility to lets say manage content through dropbox with a simple txt template and all assets in the same folder is not longer as easy as it was. Explaining users that they need to create extra txt files for each asset (wich differ by usecase) is nearly impossible and limits them to use the panel.
To you question where it should go: the same folder you’re currently creating the content.
I actually think that nothing has changed if you don’t use the Panel. The only problem that arises is when you mix using the Panel and not using the Panel. We are still creating content for the getkirby.com website in a text editor without ever using the Panel and nothing whatsoever has changed.
That does only make sense if your files field actually queries files of the current page. But the files in your files field might be from anywhere, maybe the parent, maybe a completely different page. Guess that could also be controlled via a blueprint setting.
There is already an issue in GitHub in the ideas repo:
Don’t make it to complicated: The files field can still query all files - just the upload should be in context of the current page.
I get all the usecases but think there should be a simpler fallback option.
And yes we have mixed users: some of them prefering using the panel and some using synced files.
We use kirby in an internal knowledge base. I need to probably creates something in the template that queries for either or.