Query to get all (uploaded) files of a Kirby instance

Is there one query to get all files ever uploaded to the Kirby instance, no matter they belong to site or any pages or subpages?

You should be able to get all files with


Note that calls to $site->index() should be used with care: https://getkirby.com/docs/reference/objects/site/index#details

1 Like

Nice, works like a charm (except that it seems that add does not work when the query is used in the kql plugin, but I find a way around that certainly).

Regarding the warning, do you know how the caching works in that regard? Is there a large hit when calling site.index() multiple times or will it return results from a cache?

As I only make one huge API request during static side generation, but which contains multiple queries.

If you don’t have a huge site, there is no reason to worry.

I have no idea if or how caching works in the KQL context…

It might make sense to set up a cache for this collection though, maybe in a plugin with some logic to purge the cache when needed.

1 Like

Alright. Thank you very much for your prompt responses and your help. Very appreciated.