From: Jan Szejko Date: Thu, 2 Feb 2017 13:04:40 +0000 (+0100) Subject: no thumbnail for no image X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/c96b1bfa73a18c8647fdc7ec3988b85961ea2c5f no thumbnail for no image --- 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