Tidy up my thumbs

Hi. I adjusted how my images optimze/resize the images after the site launched in an effort to further shrink 'em. I’d like to remove unused images. I suspect I can just remove the folders in my ‘thumbs’ directory and the site will regenerate all the necessary images on the fly. Right?

Yes (and some more characters).

Cool. Thanks (and some more characters)!

I use NPM scripts to do this automatically during build:

"config": {
  ...
  "content": "./public/content",
  "thumbs": "./public/thumbs",
  ...
},
"scripts": {
  ...
  "images:content:min": "imageoptim -d $npm_package_config_thumbs && imageoptim -d $npm_package_config_content && find $npm_package_config_content -name '*.svg' -type f -exec svgo  {} \\;",
  ...
}

Requires Imageoptim, Imageoptim CLI and SVGO installed. Will optimise all images and SVG files recursively in the content and thumbs folders. Don’t use the quality settings on Kirby’s image helpers because you will effectively be compressing images twice, which can look bad if your not careful.

Whilst this does use a Mac only app to do the optimising, windows folks can get a similar result by swapping it out for Imagemin which is cross platform.

2 Likes