summaryrefslogtreecommitdiff
path: root/app/blog/widgets.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/blog/widgets.py')
-rw-r--r--app/blog/widgets.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/app/blog/widgets.py b/app/blog/widgets.py
index 64509c2..ec1bd1d 100644
--- a/app/blog/widgets.py
+++ b/app/blog/widgets.py
@@ -1,15 +1,15 @@
+import os
from django.contrib.admin.widgets import AdminFileWidget
-from django.utils.translation import ugettext as _
from django.utils.safestring import mark_safe
from django.conf import settings
-from PIL import Image
-import os
+
def thumbnail(image_path):
absolute_url = os.path.join(settings.IMAGES_URL, image_path[7:])
print(absolute_url)
return '<img style="max-width: 400px" src="%s" alt="%s" />' % (absolute_url, image_path)
+
class AdminImageWidget(AdminFileWidget):
"""
A FileField Widget that displays an image instead of a file path
@@ -21,6 +21,6 @@ class AdminImageWidget(AdminFileWidget):
if file_name:
file_path = '%s' % (file_name)
output.append('<a target="_blank" href="%s">%s</a>' % (file_path, thumbnail(file_name)))
-
+
output.append(super(AdminFileWidget, self).render(name, value, attrs))
return mark_safe(''.join(output))