There are over 4000 images on my site I want to make selections for an inspiration board but my current strategy is really slow and expensive.
title: Inspiration
fields:
gallery:
type: files
query: site.index.find('interviews').children.listed.notfuture.flip.images
layout: cards
uploads: false
pages:
type: pages
label: Select images
limit: 20
search: false
I’m looking for a more efficient way to do this.
Are these two fields, there is to pages property in a files field.? Something looks wrong here.
Also, how many pages called interview are there. I think the query is wrong and should be
query: site.find('interviews').children.listed.notfuture.flip.images
But querying 4000 images will probably be slow anyway…
You could use a custom site method for this query. In the site method you could use a custom cache: Caching | Kirby
Then it would be just query: site.interviewImages
and the results are cached.
2 Likes
Ahh this is interesting as there are new image added so it will only need to cache new ones.
Any idea how I could do this exactly? The site method I could create but I’m not familiar with custom caching.
Putting something in a custom cache is quite easy:
$cache = $kirby->cache('yourCache');
$cachedImages = $cache->get('interviewImages');
if ($cachedImages === null) {
$cache->set('interviewImages', site()->index()->find('interviews')->children()->listed()->notfuture()->flip()->images());
}}
(Untested)