Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion imagekit/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,19 @@ def __init__(self, image_field, template=None):
def __call__(self, obj):
if callable(self.image_field):
thumbnail = self.image_field(obj)
generator = getattr(thumbnail, 'generator', None)
if generator:
original_image = getattr(generator, 'source', thumbnail)
else:
original_image = thumbnail
else:
try:
thumbnail = getattr(obj, self.image_field)
original_image = getattr(thumbnail, 'source', None) or thumbnail
except AttributeError:
raise Exception('The property %s is not defined on %s.' %
(self.image_field, obj.__class__.__name__))

original_image = getattr(thumbnail, 'source', None) or thumbnail
template = self.template or 'imagekit/admin/thumbnail.html'

return render_to_string(template, {
Expand Down
Loading