Find all images in all pages

Hey people.

First of all, thanks for Kirby and the forum.

I have been browsing the forum for my question, yet couldnt find a definitive answer. Basically I would like to be able to query all pages/folders for images. If I need a model thats fine, but I want it to be reused on different pagenames. Perhaps a reusable image-template that activates the model or something?

site.find(‘pagename’).children.images

That works, but only for one page/folder. I want to scan and get images from all pages/folders.

Any ideas?

You should be able to do:

site.children.images

And to clarify what you tried before:

site.find(‘pagename’).children.images

That would actually get the images on the child pages of pagename, not the images on pagename, if that makes sense.

1 Like

Or site.index.images to get images from all folders down the tree.

2 Likes

@jimbobrjames

Yes, I know the find(‘pagename’) only gets me children/images from that page. Thanks though.

site.children.images 

Did not work for me

@texnixe

site.index.images

Brilliant! Works like a charm.

While at it, although this works, is it possible to show a larger image in the popup listing the images?

Not out of the box.

You could do something with a custom stylesheet, but then your image would get blurry, because it is a fixed size.

The alternative would be a custom field with its own modal. Actually, a card style modal would be quite nice for the image field.

Edit: you could try and make the image 76px x 76px in a custom panel stylesheet and check if that’s still OK for you. At least that would be the quick and dirty solution (not awfully beautiful…).

1 Like

Yes, well i think this looks good (for certain cases). Thats where i would like to go.

For now, since the classes are too general for all image layouts it would affect all layouts, and it seems to break listed pages with icons. Could ofcourse be fixed, but I like those at 38x38.

Would be nice to someday have this as an option, so it wont break other installs.

@texnixe

One use-case I am looking into is the hero image. It’s a max: 1 so would be nice to show a bigger image there.

If you limit the setting to the list image inside the dialog, it should actually work. If you use this setting in conjunction with https://github.com/mullema/k3-panel-view-extended, you could limit your custom styles to individual pages.

To show the hero image bigger, you can switch to card style

layout: cards

I thought you were referring to the add modal…

I was/am. I know i can list it as a card, but i’m using a 100% width layout for the image to somehwat respresent the flow of the page (frontend). It’s aesthetically more pleasing when its a single image and displayed a little larger. I didnt want to go to WP route and have a featured (card)image on the right.

It also does look good to me in the images popup panel at 78px. Having multiple images listed as a section at 38px works fine for me.