Like using Zenphoto? Donate!

pre-cache script

hey guys, I just wanted to let you know i've created a zenphoto pre-cache script that will iterate across all gallery images and discover what cached thumbnails and whatnot are missing, and generate them. it is suitable to run in cron once an initial run has been completed. https://github.com/benklop/zenphoto-precache if you want to take a look. so far it seems to work pretty well.

Thanks, contributions like this are always welcome. I will add it to the extensions section soon.

Are you aware that there is already a pre-cache facility provided by the included cacheManager plugin via a utility button? However, to work properly themes and plugins need to register any image size they use. (Edit: I see your script can be used as a cron job which is indeed different).

I loosely based this on the python script you mentioned, though by the time i was done just about all of it was replaced. I did know about cacheManager, and in fact used it as a reference when figuring out how to extract information from the database to make this script work.

At first I made this because CacheManager works through the browser, and it will try to render more than one image at once which totally overwhelms my sad little server. Running it via cron to automatically keep things pre-cached is really my ultimate goal at this point, though.

This script also has the same limitations that the themes (and plugins too i'd imagine) need to register their image sizes.

I haven't tried to detect enabled plugins, though you can give the script a --themes flag with a list of additional theme (and i'd assume plugin) names to enable.

how are enabled plugins stored in the database? If I can get that info, I could pretty easily have this automatically cache needed image sizes from plugins too.