no thumbnail for no image
authorJan Szejko <janek37@gmail.com>
Thu, 2 Feb 2017 13:04:40 +0000 (14:04 +0100)
committerJan Szejko <janek37@gmail.com>
Thu, 2 Feb 2017 13:04:40 +0000 (14:04 +0100)
apps/fileupload/views.py

index 89ccf08..35e0a7a 100644 (file)
@@ -23,7 +23,11 @@ except ImportError:
 else:
     def thumbnail(relpath):
         try:
 else:
     def thumbnail(relpath):
         try:
-            return default.backend.get_thumbnail(relpath, "x50").url
+            thumb = default.backend.get_thumbnail(relpath, "x50")
+            if not thumb.exists():
+                # That's not an image. No thumb.
+                return None
+            return thumb.url
         except IOError:
             # That's not an image. No thumb.
             return None
         except IOError:
             # That's not an image. No thumb.
             return None