From ea953629c654b6264ef2e4932307bbccaf8c41d9 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 20 Sep 2016 11:55:52 +0200 Subject: Don't crash if an icon is missing on the HDD --- chimere/models.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/chimere/models.py b/chimere/models.py index ae1e014..e0b401b 100644 --- a/chimere/models.py +++ b/chimere/models.py @@ -356,12 +356,19 @@ class SubCategory(models.Model): return cats def getJSONDict(self): + # don't crash if some image have disapears + try: + width = self.icon.image.width + height = self.icon.image.height + except IOError: + width = 0 + height = 0 items = {'id': self.pk, 'name': self.name, 'description': self.description if self.description else '', 'icon': {'url': self.icon.image.url, - 'width': self.icon.image.width, - 'height': self.icon.image.height, + 'width': width, + 'height': height, 'offset_x': self.icon.offset_x, 'offset_y': self.icon.offset_y, 'popup_offset_x': self.icon.popup_offset_x, -- cgit v1.2.3