I have an ImageWithThumbs field class derived from ImageField class
that manages thumbnails of an image. It takes list of dimensions as a
parameter and handles the creation and deletion of the resized
images.

I want to dynamically add methods to return the url of a resized image
when its dimensions are given so that I can access them from the
templates.

In other words, if there is an image resized to 60 x 60 pixels, there
should be a method called image_60x60_url which will return the url of
the resized image.

I tried setattr in the save_file method in the field class as follows:

setattr(self, 'image_%dx%d_url' % (width, height), self.get_url(dim))

where get_url is the method that takes the dimension of the image
being created and returns the url to that image.

This didn't work, because, I think this method does not persist in the
class' scope.

Then I tried contribute_to_class but I couldn't figure out how exactly
it works and after some trial and error, I decided to ask for help.

Thanks...

oMat


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to