[Answered ]-When does Django ImageKit create the thumbnail file?

1👍

I don’t get it 100%, but from what I understood the thumbnail is a generator that is only called when the thumbnail is first requested, and is then cached.

My personal experience with it suggests so as well. I created a dummy instance of the model (same code as above) through the admin interface. I then created an html page that displays the thumbnails with template tagging (<img src="instance.thumbnail.url">). Checking my folders, no images generated so far. Then I launch a server, navigate to that page. It takes unusual time to load (that’s an indication that the thumbnails are being created) on the first try, but then it speeds up. And the files are there.

1👍

By default, ImageKit generates ImageSpecField images when they are needed, not when the model object is created. To change the behavior, you can use the cache file strategies. Default value of IMAGEKIT_DEFAULT_CACHEFILE_STRATEGY is JustInTime, which can be changed to Optimistic which creates images on model object creation, or to custom strategy.

Moreover, you can set different strategies for individual ImageSpecFields by providing the cachefile_strategy parameter.

Leave a comment