From c96b1bfa73a18c8647fdc7ec3988b85961ea2c5f Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Thu, 2 Feb 2017 14:04:40 +0100 Subject: [PATCH] no thumbnail for no image --- apps/fileupload/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/fileupload/views.py b/apps/fileupload/views.py index 89ccf081..35e0a7ae 100644 --- a/apps/fileupload/views.py +++ b/apps/fileupload/views.py @@ -23,7 +23,11 @@ except ImportError: 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 -- 2.20.1