diff --git a/cubedash/_filters.py b/cubedash/_filters.py index f28c9b369..54c9c97cf 100644 --- a/cubedash/_filters.py +++ b/cubedash/_filters.py @@ -121,6 +121,17 @@ def _dataset_created(dataset: Dataset): def _dataset_file_paths(dataset: Dataset): return utils.get_dataset_file_offsets(dataset) +@bp.app_template_filter("dataset_thumbnail_url") +def _dataset_thumbnail_url(dataset: Dataset): + file_paths = _dataset_file_paths(dataset) + if "thumbnail:nbart" in file_paths: + offset = file_paths['thumbnail:nbart'] + elif "thumbnail" in file_paths: + offset = file_paths['thumbnail'] + else: + return "" + return _to_remote_url(offset, dataset.uris[0]) + @bp.app_template_filter("resolve_remote_url") def _to_remote_url(offset: str, base_uri: str = None): diff --git a/cubedash/templates/dataset.html b/cubedash/templates/dataset.html index f0c394a52..603b655be 100644 --- a/cubedash/templates/dataset.html +++ b/cubedash/templates/dataset.html @@ -3,7 +3,7 @@ {% block title %}{{ dataset | printable_dataset }}{% endblock %} {% set extent_geojson = dataset_footprint.__geo_interface__ %} -{% set thumbnail_url = [] %} +{% set thumbnail_url = dataset | dataset_thumbnail_url %} {% block head %} {{ super() }} @@ -144,15 +144,9 @@