diff --git a/app.py b/app.py index 73e2d14..eef62f2 100755 --- a/app.py +++ b/app.py @@ -345,13 +345,15 @@ def image_with_cache(qid, image_filename, width): filename = f'cache/{qid}_{width}_image.json' detail = json.load(open(filename)) if os.path.exists(filename) else {} + image_filename = image_filename.replace('_', ' ') + # The image associated with an item can change. # If that happens the detail in the cache will be for the wrong file. if not detail or image_filename not in detail: detail = commons.image_detail([image_filename], thumbwidth=width) json.dump(detail, open(filename, 'w'), indent=2) - return detail[image_filename] + return detail.get(image_filename) def existing_depicts_from_entity(entity): if 'P180' not in entity['claims']: