I want to generate a thumnail list. I opted for sorl-thumbnail because it seems largely used and developped.
My problem is with the template tag "thumbnail": it generates the thumbnail image and the thumbnail object correctly but I only want the url.
I don't mind if the thumbnail image is not already generated/ready, only the template generation concerns me. I can serve my thumbnails through a custom view, this is not a problem as those will only be available to few people.
So to simplify I want to de-couple the url generation from the thumbnail generation itself.
Is it possible with sorl-thumbnail? if not, do you know another project that can?
I prefer not writing my own if something can already do it.
P.S. I will store thumbnails on disk.
I faced exactly the same issue early in my Django experience. I had a requirement that all generated thumbnails are stored on disk. We also had an issue on the deployment server with PIL (back then several problems with Python 3).
We couldn't find anything to help us, so we ended up with the following. We also ended up being imagemagick from command line to avoid PIL.
The idea was to create a custom tag asking for a thumbnailed image. If that would not exist, the tag would create the thumbnail and store it on disk for later use (in a subdir with the name of the style). Therefore there is a delay only the first time someone visits the page. This idea comes from Drupal.
Also, the thumbnail dimensions are specific so we hard-coded them on the project settings, but it shouldn't be too difficult to change this.
Frankly, I am not sure if this is the best solution, but it still works. Also it was one of my early codes in Python so be gentle with it (right now I am fully aware about eg.
os.join
etc, but no time to improve and test yet; but I am also very interested in your constructive opinion).First, here are the settings:
This is the custom tag:
This is how to use in ntemplate: