I’m trying to use the query option from the files field inside the image block of the blocks editor. Is there a way to achieve this?
This is what I tried so far, but it doesn’t work. In the site-blueprint i defined a files section called gallery. Ins the blueprint of the page containing the blocks editor I tried this:
text:
label: Text
type: blocks
fieldsets:
- text
- image
- markdown
- video
- list
- heading
image:
extends: blocks/image
query: site.gallery
This cannot possibly work, toFiles() is a method you call on a files field, but you are using a section. The sole purpose of a section is to upload files to a page/the site object, which you can later retrieve with
What’s strange is, that on the same blueprint I have a normal files field that looks like this:
myimagefield:
type: files
query: site.images
uploads:
parent: site
And there it works fine. Only in the block I cannot make it work… I updated Kirby to 3.9.1 but still no change… Is there something else I’m missing here?
Yes, that is a different blueprint. It’s the blueprint for posts in a blog, where I use the blocks editor. Here i define the blocks (the blueprint is very long, so I’m just pasting the blocks part here):
text:
label: Text
type: blocks
fieldsets:
- text
- image
- markdown
- video
- list
- heading
selectimage:
extends: blocks/image
query: site.images
name: Select Image...
uploads:
parent: site
columns:
extends: blocks/columns
fields:
layout:
layouts:
- "1/2, 1/2"
fieldsets:
- heading
- text
- image
- list
That query cannot possibly work because you are applying in on the block type instead of on the field in the block type. Better create a new yaml file for your new block, that will make it clearer.