Skip to content

Commit

Permalink
mirador: only view images > IIIF tile size
Browse files Browse the repository at this point in the history
  • Loading branch information
yashlamba authored and 0einstein0 committed Jul 5, 2024
1 parent 7e2ef7a commit ec4c3c5
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions site/zenodo_rdm/previewer/mirador.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,21 @@ def can_preview(file):
# supported_extensions list needs . prefixed -
preview_extensions = current_app.config["MIRADOR_PREVIEW_EXTENSIONS"]
supported_extensions = ["." + ext for ext in preview_extensions]

return file.has_extensions(*supported_extensions)
if not file.has_extensions(*supported_extensions):
return False

iiif_config = current_app.config["IIIF_TILES_CONVERTER_PARAMS"]
metadata = file.data["metadata"]
# If any of metdata, height or width aren't present, return false
if not (metadata and "height" in metadata and "width" in metadata):
return False
elif (
metadata["width"] <= iiif_config["tile_width"]
or metadata["height"] <= iiif_config["tile_height"]
):
return False

return True


def preview(file):
Expand Down

0 comments on commit ec4c3c5

Please sign in to comment.