From 16597ab0f8590cade4abdd2ef18d07ef0ad2d3d2 Mon Sep 17 00:00:00 2001 From: Richard Doe Date: Wed, 27 Nov 2024 13:18:54 +0000 Subject: [PATCH] feat: thumbnail fallback for non-viewable media, e.g. PDFs, isShownAt, TIFFs and use same for viewable images without IIIF service until the thumbnail is interacted with --- .../components/item/ItemMediaPresentation.vue | 81 ++++++++----------- .../components/item/ItemMediaThumbnail.vue | 8 +- .../components/item/ItemMediaThumbnails.vue | 2 +- .../src/components/media/MediaCardImage.vue | 17 +++- .../src/components/media/MediaImageViewer.vue | 68 +++------------- packages/portal/src/composables/thumbnails.js | 0 packages/portal/src/pages/item/_.vue | 4 +- .../src/plugins/europeana/edm/WebResource.js | 30 ++----- .../portal/src/plugins/europeana/thumbnail.js | 13 ++- 9 files changed, 83 insertions(+), 140 deletions(-) create mode 100644 packages/portal/src/composables/thumbnails.js diff --git a/packages/portal/src/components/item/ItemMediaPresentation.vue b/packages/portal/src/components/item/ItemMediaPresentation.vue index 357f4e11eb..95c628435c 100644 --- a/packages/portal/src/components/item/ItemMediaPresentation.vue +++ b/packages/portal/src/components/item/ItemMediaPresentation.vue @@ -43,14 +43,13 @@ :provider-url="providerUrl" /> - - - - -
{{ JSON.stringify(resource?.edm, null, 2) }}
-            
-
import LoadingSpinner from '../generic/LoadingSpinner.vue'; + import MediaCardImage from '../media/MediaCardImage.vue'; import useItemMediaPresentation from '@/composables/itemMediaPresentation.js'; export class ItemMediaPresentationError extends Error { @@ -161,9 +137,9 @@ ItemMediaThumbnails: () => import('./ItemMediaThumbnails.vue'), LoadingSpinner, MediaAudioVisualPlayer: () => import('../media/MediaAudioVisualPlayer.vue'), + MediaCardImage, MediaImageViewer: () => import('../media/MediaImageViewer.vue'), - MediaImageViewerControls: () => import('../media/MediaImageViewerControls.vue'), - MediaPDFViewer: () => import('../media/MediaPDFViewer.vue') + MediaImageViewerControls: () => import('../media/MediaImageViewerControls.vue') }, props: { @@ -221,7 +197,8 @@ return { fullscreen: false, showPages: true, - showSidebar: !!this.$route.hash + showSidebar: !!this.$route.hash, + thumbnailInteractedWith: false }; }, @@ -259,6 +236,14 @@ }, computed: { + displayThumbnail() { + return !(( + (this.viewableImageResource && (this.service || this.thumbnailInteractedWith)) || + this.resource?.edm?.isPlayableMedia || + this.resource?.edm?.isOEmbed + )); + }, + hasManifest() { return !!this.uri; }, @@ -271,20 +256,16 @@ return this.resourceCount >= 2; }, - thumbnail() { - return this.resource?.edm.thumbnails?.(this.$nuxt.context)?.large; - }, - - imageTypeResource() { - return this.resource?.edm.isHTMLImage; + viewableImageResource() { + return this.resource?.edm?.isHTMLImage; }, addPaginationToolbarMaxWidth() { - return !this.imageTypeResource && this.multiplePages; + return !this.viewableImageResource && this.multiplePages; }, addSidebarToggleMaxWidth() { - return !this.imageTypeResource && this.sidebarHasContent; + return !this.viewableImageResource && this.sidebarHasContent; } }, @@ -299,6 +280,12 @@ } }, + mounted() { + console.log('IMP resource', this.resource); + console.log('IMP resource.edm', this.resource?.edm); + console.log('IMP resource.edm.preview', this.resource?.edm?.preview); + }, + methods: { handleImageError(error) { this.$fetchState.error = error; diff --git a/packages/portal/src/components/item/ItemMediaThumbnail.vue b/packages/portal/src/components/item/ItemMediaThumbnail.vue index d201ae81c8..c946b015fa 100644 --- a/packages/portal/src/components/item/ItemMediaThumbnail.vue +++ b/packages/portal/src/components/item/ItemMediaThumbnail.vue @@ -4,7 +4,7 @@ class="item-media-thumbnail text-lowercase text-decoration-none" > import MediaCardImage from '../media/MediaCardImage.vue'; - import EuropeanaMediaResource from '@/utils/europeana/media/Resource.js'; + import WebResource from '@/plugins/europeana/edm/WebResource.js'; export default { name: 'ItemMediaThumbnail', @@ -33,7 +33,7 @@ }, props: { resource: { - type: EuropeanaMediaResource, + type: WebResource, required: true }, offset: { @@ -62,7 +62,7 @@ return this.offset + 1; }, mediaTypeIconClass() { - const mediaType = this.resource.edm.edmType || this.edmType; + const mediaType = this.resource.edmType || this.edmType; return mediaType ? `icon-${mediaType.toLowerCase()}-bold` : ''; }, label() { diff --git a/packages/portal/src/components/item/ItemMediaThumbnails.vue b/packages/portal/src/components/item/ItemMediaThumbnails.vue index 38198f94d7..0b4304e5bb 100644 --- a/packages/portal/src/components/item/ItemMediaThumbnails.vue +++ b/packages/portal/src/components/item/ItemMediaThumbnails.vue @@ -35,7 +35,7 @@ :offset="firstRenderedResourceIndex + index" class="d-flex-inline mr-3 mr-lg-auto" :class="{ 'selected': index === selectedIndex }" - :resource="resource" + :resource="resource.edm" :edm-type="edmType" :lazy="true" /> diff --git a/packages/portal/src/components/media/MediaCardImage.vue b/packages/portal/src/components/media/MediaCardImage.vue index 1e1ae26216..4566aa459e 100644 --- a/packages/portal/src/components/media/MediaCardImage.vue +++ b/packages/portal/src/components/media/MediaCardImage.vue @@ -55,6 +55,10 @@