Commits

Anonymous committed 65e5332

Add thumb to gallery image inline

  • Participants
  • Parent commits a7d36f9

Comments (0)

Files changed (1)

gnocchi/gallery/admin.py

 
 class ImageInline(admin.TabularInline):
     model = models.Image
-    readonly_fields = ('width', 'height',)
+    fields = ('image', 'thumb', 'name', 'tags', 'width', 'height',)
+    readonly_fields = ('thumn', 'width', 'height',)
+
+    def thumb(self, obj):
+        img = get_thumbnailer(obj.image).get_thumbnail({'size': (70, 70,)})
+        return '<img src="%s" alt="">' % (img.url,)
+    thumb.short_description = 'Thumbnail'
+    thumb.allow_tags = True
 
     if HAS_GRAPPELLI:
         sortable_field_name = 'order'