Don't crash when there is no image.
This commit is contained in:
parent
2a819fb8b1
commit
66cbf3b670
3
app.py
3
app.py
|
@ -333,7 +333,10 @@ def item_page(item_id):
|
||||||
|
|
||||||
width = 800
|
width = 800
|
||||||
image_filename = item.image_filename
|
image_filename = item.image_filename
|
||||||
|
if image_filename:
|
||||||
image = image_with_cache(qid, image_filename, width)
|
image = image_with_cache(qid, image_filename, width)
|
||||||
|
else:
|
||||||
|
image = None
|
||||||
|
|
||||||
# hits = item.run_query()
|
# hits = item.run_query()
|
||||||
label_and_language = get_entity_label_and_language(entity)
|
label_and_language = get_entity_label_and_language(entity)
|
||||||
|
|
|
@ -100,6 +100,7 @@ class Painting:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def image_filename(self):
|
def image_filename(self):
|
||||||
|
if 'P18' in self.entity['claims']:
|
||||||
return self.entity['claims']['P18'][0]['mainsnak']['datavalue']['value']
|
return self.entity['claims']['P18'][0]['mainsnak']['datavalue']['value']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -203,7 +204,8 @@ class Painting:
|
||||||
if not titles:
|
if not titles:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
cat_list = mediawiki.get_categories(titles, 'commons')
|
# cat_list = mediawiki.get_categories(titles, 'commons')
|
||||||
|
cat_list = []
|
||||||
|
|
||||||
for title, cats in cat_list:
|
for title, cats in cat_list:
|
||||||
for cat in cats:
|
for cat in cats:
|
||||||
|
|
Loading…
Reference in a new issue