Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

BK-74 Page breaks when trying to make thumbnail of non image attachment.

  • Loading branch information...
commit e833c937c9c0bc4e1f92f68d7c5b1236e41af431 1 parent f2e3cd4
@aerkalov aerkalov authored
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/booki/editor/views.py
View
8 lib/booki/editor/views.py
@@ -179,9 +179,13 @@ def thumbnail_attachment(request, bookid, attachment, version=None):
# should have one "broken image" in case of error
import Image
- im = Image.open(document_root)
- im.thumbnail((150, 150), Image.ANTIALIAS)
+ try:
+ im = Image.open(document_root)
+ im.thumbnail((150, 150), Image.ANTIALIAS)
+ except IOError:
+ im = Image.new('RGB', (150,150), "white")
+
response = HttpResponse(mimetype='image/jpeg')
im.save(response, "jpeg")
return response
Please sign in to comment.
Something went wrong with that request. Please try again.