I’m using Optimize uploaded images: create that was introduced in Kirby 4 to resize images to a max size of 3200 when they are uploaded in the panel, to avoid the large high res files taking up space on the server.
If I want to change the size or just to regenerate all the images in the content folder, is there a way to do that without manually uploading all the image files to every page that already has images uploaded?
You can resize or re-upload files programmatically (i.e. you need to write a script). The create option in the blueprint only works while uploading through the Panel, though.
I’m not aware of a script. In general, to prevent having to do this, I would make sure to choose the create options wisely, i.e.not too small, so that the images are large enough to cover all potential use cases. There is pro
To re-generate the files, especially if you want to make them larger, you need access to the original files.
Then loop through all existing files, find its equivalent original, and replace the existing file with a differently resized version of the original.
What is your use case? Should an editor be able to do this? Or is this just a case during development?
Just a case during development, since many of the pages uploaded contain images that are much larger than needed and I want to batch convert them to 3200px so they are easiest to process/store on the server.
If the files that are too large are the original files, then it would just be a matter of looping through the complete page index, and then through all files and resize them. Of course, you could also resize those that have already been resized (but I don’t know if that might have an effect on the quality of the images), the autoresize method from an old plugin might help (ignore the hooks):