Hi, Iād like to share one of my thumbnail.destination functions.
I didnāt want to create the thumbnails of every page in a central directory so I created a āthumbs.destinationā-function which creates them in a subdirectory to their position. Kirby >= 2.1.0 is needed.
Example
The thumbnail for the image in ā/content/page1/image.jpgā was ā/thumbs/image-123456.jpgā.
The new location is ā/content/page1/thumbs/image-123456.jpgā
Source
Insert the following in ā/site/config/config.phpā
This is a great idea. Frankly, it doesnāt bother me that the thumbs are stored elsewhere (after all, they arenāt content, theyāre consequential/cached data of the application), but itās nice to know this kind of thing is possible. For anyone tracking their content folder in Git (or a secondary git repository), the unified thumbs directory could actually be pretty useful. Some may have strong opinions about the separation between editorial and generated content.
How does the panel deal with this additional folder? You may need to addā¦
c::set('content.file.ignore',array('thumbs'));
ā¦to config.php in order to prevent Kirby from acknowledging the thumbs directory as a āpage.ā
I manage a website with some pages here. Most of the pages contain a image-gallery with >10 images on it.
Each image is rendered (via thumb) in different sizes to cover mobile clients (iPhone, iPad) and desktops (with and without Retinadisplays).
When a new article is published the thumbnails are created in a subdirectory of the page and not 4000 pictures in one directory.
When I remove an article i donāt have to look after every thumbnail. Sometimes I change pictures in a gallery and need them to be re-resized. Now I just have to remove the t-directory and the thumbs are recreated.
I think itās hard to figure out which of these two structures are the best one. Right know I think yours are, but that can change.
Root thumbs folder (default)
Benefits
Easy to remove all when needed.
Separate generated data and content.
Problems
The generated thumbnail does not get deleted when the page is deleted.
The generated thumbnail does not get deleted when the image size is not longer used in the template.
If clearing the thumbs folder often it will make a heavy load on services like tinypng, if used.
Content thumbs folder
Benefits
When removing a page, the thumbs are deleted.
When a thumbnail size is no longer used itās not deleted, but it will automatically be fixed when creating and deleting pages, in time.
When using services like tinypng, itās good to not remove and regenerate the images too often. With this structure there is no need for clearing the thumbs folder.
Problems
The images are scattered through the content folders.
Generated data is mixed with the content.
Summery
I will probably have the thumbs in the content folders because I like to only have generated thumbnails to images that actually still exists. I donāt want to regenerate all the thumbnails too often because I might use tinypng.