Reputation: 866
Understanding that I should probably just dig into the source to come up with a solution, I'm wondering if anyone has come up with a tactic for dealing with this.
In my project, I have a lot of images being generated outside of the application. I'm isolating them on the filesystem based on a model's pk.
For example, a model instance with a pk of 121 might have the following images:
.../src_pics/1/2/1/img.1.jpg
.../src_pics/1/2/1/img.2.jpg
...
.../src_pics/1/2/1/img.27.jpg
Since the image filenames themselves are not guaranteed to be unique, I'm looking for a way to inform sorl (at runtime) that I'd like to prefix thumbs for this model with the instance pk value. Is this even possible without patching sorl?
Upvotes: 1
Views: 219
Reputation: 866
Ah hah. Well it looks like the solution was staring me in the face the whole time. http://thumbnail.sorl.net/docs/#this-just-doesn-t-cover-my-cravings
Looks like I'm going to subclass sorl.thumbnail.main.DjangoThumbnail and re-implement the _get_relative_thumbnail method to allow me to inject a template driven prefix for the thumbnail filename.
Upvotes: 1