class ImageWidget(forms.FileInput):
"""
A ImageField Widget that shows a thumbnail.
"""
def __init__(self, attrs={}):
super(ImageWidget, self).__init__(attrs)
def render(self, name, value, attrs=None):
output = []
if value and hasattr(value, "url"):
output.append((''
'
'
% (value.url, value.url)))
output.append(super(ImageWidget, self).render(name, value, attrs))
return mark_safe(u''.join(output))