diff --git a/wagtail/tests/fixtures/test.json b/wagtail/tests/fixtures/test.json
index d16affe480..b2e0d6f4f5 100644
--- a/wagtail/tests/fixtures/test.json
+++ b/wagtail/tests/fixtures/test.json
@@ -81,7 +81,8 @@
"audience": "public",
"location": "The North Pole",
"body": "
Chestnuts roasting on an open fire
",
- "cost": "Free"
+ "cost": "Free",
+ "feed_image": 1
}
},
@@ -625,5 +626,16 @@
"page": 11,
"password": "swordfish"
}
+},
+{
+ "pk": 1,
+ "model": "wagtailimages.image",
+ "fields": {
+ "title": "A missing image",
+ "file": "original_images/missing.jpg",
+ "width": 1000,
+ "height": 1000,
+ "created_at": "2014-01-01T12:00:00.000Z"
+ }
}
]
diff --git a/wagtail/tests/templates/tests/event_page.html b/wagtail/tests/templates/tests/event_page.html
index 795b7bf0a7..fd8f9bd757 100644
--- a/wagtail/tests/templates/tests/event_page.html
+++ b/wagtail/tests/templates/tests/event_page.html
@@ -1,4 +1,4 @@
-{% load wagtailcore_tags %}
+{% load wagtailcore_tags wagtailimages_tags %}
@@ -8,6 +8,9 @@
{{ self.title }}
Event
+ {% if self.feed_image %}
+ {% image self.feed_image width-200 class="feed-image" %}
+ {% endif %}
Back to events index
diff --git a/wagtail/wagtailimages/tests/tests.py b/wagtail/wagtailimages/tests/tests.py
index 1030a3b7ef..2c75b0611f 100644
--- a/wagtail/wagtailimages/tests/tests.py
+++ b/wagtail/wagtailimages/tests/tests.py
@@ -63,6 +63,20 @@ class TestImageTag(TestCase):
self.assertTrue('title="my wonderful title"' in result)
+class TestMissingImage(TestCase):
+ """
+ Missing image files in media/original_images should be handled gracefully, to cope with
+ pulling live databases to a development instance without copying the corresponding image files.
+ In this case, it's acceptable to render broken images, but not to fail rendering the page outright.
+ """
+ fixtures = ['test.json']
+
+ def test_image_tag_with_missing_image(self):
+ # the page /events/christmas/ has a missing image as the feed image
+ response = self.client.get('/events/christmas/')
+ self.assertContains(response, '', html=True)
+
+
class TestFormat(TestCase):
def setUp(self):
# test format