Can't reuse or search for image on posts if in draft

I am not sure if this is a setting or intentional but I cannot access/reuse image from a file field (cover/hero image) in an image block when post is in draft. Also I cannot search for the image or find it in the popup when clicking “select” in that same file field.

  1. Upload image in file field.
  2. Remove the image from the field
  3. Click select and then search for the file. It does not appear.
  4. Publish the post
  5. Click select and then search for the file. It now appears.

I believe the draft is the reason for it to not appear. Since it does not appear I cant reuse the image in the block editor.

This is the yaml:

label: Cover image
type: files
multiple: false
query: site.pages.children.images
layout: cards
uploads:
  template: image

Thanks

Right, because of your query which doesn’t include drafts, so you would have to use childrenAndDrafts()

Amazing! Thanks!

Perhaps I was too quick. I tried searching the docs for “childrenAndDrafts” as this site.pages.childrenAndDrafts.images returns “Your query must return a set of files”

I can see the that childrenAndDrafts works with $site or $page so not sure how to get this working.

I am sorry but my experience with Kirby is sadly limited.

That is because $pages doesn’t have a childrenAndDrafts() method ;), that’s only a method of a single page.

So you have two options, depending on what exactly you want to achieve. The simplest of which would be to use index(true) instead of children(). The second option a custom pages method.

That’s what I thought. Didn’t know about the index function. That did the trick. Thanks and I really appreciate the speedy replies.

Although I don’t use Kirby much I do really love what you are doing and wish I could use it more.