views:

32

answers:

1

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?

A: 

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.

Owen Nelson
Perhaps I don't even need to do that... I need to do some testing as I'm not that familiar with the path of execution sorl goes though. Looks like I may just be able to pass prefix in the template tag as one of the keyword args. That would be ideal.
Owen Nelson