mirror of https://github.com/interlegis/sigi.git
Gilson Filho
13 years ago
2 changed files with 24 additions and 0 deletions
@ -0,0 +1,15 @@ |
|||||
|
from django.contrib.admin.widgets import AdminFileWidget |
||||
|
from django.utils.translation import ugettext as _ |
||||
|
from django.utils.safestring import mark_safe |
||||
|
|
||||
|
class AdminImageWidget(AdminFileWidget): |
||||
|
def render(self, name, value, attrs=None): |
||||
|
output = [] |
||||
|
if value and getattr(value, "url", None): |
||||
|
image_url = value.url |
||||
|
file_name=str(value) |
||||
|
output.append( |
||||
|
u' <a href="%s" target="_blank"><img src="%s" width="200" alt="%s"/></a> <br/> %s' % \ |
||||
|
(image_url, image_url, file_name, _('Change:'))) |
||||
|
output.append(super(AdminFileWidget, self).render(name, value, attrs)) |
||||
|
return mark_safe(u''.join(output)) |
Loading…
Reference in new issue