Generate thumbnails before they are requested

Is there is a way to generate thumbnails throughout the site without requesting them from the front end? I have a site with a lot of images using srcset, so visiting the front end page only generates the thumbnails for that breakpoint. If someone visits the site for a breakpoint that has not been generated, it’s going to be very slow.

I know I could use a hook to generate thumbnails when the image is uploaded to the panel, but I’m looking for a way to do it now that everything is already there. Thanks

This script by @lukaskleinschmidt generates all thumbnails on your site: https://gist.github.com/lukaskleinschmidt/40014aad9884b449a2f183e53f147c3a

3 Likes

Thank you @thguenther and @lukaskleinschmidt
But how is this script meant to be used? It’s not clear to me from the gist.

Do you create three new folders in the project root?
public/index.php
bootstrap/kirby.php
tools/thumbs.php

Checkout this plugin: https://github.com/bnomei/kirby3-janitor#custom-jobs

It has a job for pre-generating thumbs as well.

2 Likes

The janitor plugin did the trick. Thank you @texnixe!

1 Like