mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-13 09:43:10 +00:00
catch SourceImageIOError when rendering image formats - fixes #801
This commit is contained in:
parent
fbf0d9002c
commit
6e232d74e1
1 changed files with 10 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
from django.utils.html import escape
|
||||
|
||||
from wagtail.utils.apps import get_app_submodules
|
||||
from wagtail.wagtailimages.models import SourceImageIOError
|
||||
|
||||
|
||||
class Format(object):
|
||||
|
|
@ -25,7 +26,15 @@ class Format(object):
|
|||
)
|
||||
|
||||
def image_to_html(self, image, alt_text, extra_attributes=''):
|
||||
rendition = image.get_rendition(self.filter_spec)
|
||||
try:
|
||||
rendition = image.get_rendition(self.filter_spec)
|
||||
except SourceImageIOError:
|
||||
# Image file is (probably) missing from /media/original_images - generate a dummy
|
||||
# rendition so that we just output a broken image, rather than crashing out completely
|
||||
# during rendering
|
||||
Rendition = image.renditions.model # pick up any custom Image / Rendition classes that may be in use
|
||||
rendition = Rendition(image=image, width=0, height=0)
|
||||
rendition.file.name = 'not-found'
|
||||
|
||||
if self.classnames:
|
||||
class_attr = 'class="%s" ' % escape(self.classnames)
|
||||
|
|
|
|||
Loading…
Reference in a new issue