From 5f15bf9cf8e008dba04a5babfa940c92479c1986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFs=20Poujade?= <lois.poujade@tetras-libre.fr> Date: Tue, 17 Jan 2023 16:28:15 +0100 Subject: [PATCH] Minimal adaptation for images in annotations - read all body to find images - show both FragmentSelector and SVG Selector --- src/components/AnnotationsOverlayVideo.js | 14 ++++++++------ src/lib/CanvasAnnotationDisplay.js | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/components/AnnotationsOverlayVideo.js b/src/components/AnnotationsOverlayVideo.js index bc4562cfc..95c63bd0f 100755 --- a/src/components/AnnotationsOverlayVideo.js +++ b/src/components/AnnotationsOverlayVideo.js @@ -417,13 +417,14 @@ export class AnnotationsOverlayVideo extends Component { return { height: 0, width: 0 }; } - /** @private */ + /** @private - Returns the first Image body */ getResourceImage(resource) { - let imageSource; - if (resource.body && resource.body.length > 0 && resource.body[0].type === 'Image') { - const src = resource.body[0].id; + const imageSource = []; + + for (const body of resource.body.filter(b => b.type === 'Image')) { + const src = body.id; if (this.imagesReady[src]) { - imageSource = this.imagesReady[src]; + imageSource.push(this.imagesReady[src]); } else if (!this.imagesLoading.includes(src)) { this.imagesLoading.push(src); const img = new Image(); @@ -433,7 +434,8 @@ export class AnnotationsOverlayVideo extends Component { img.src = src; } } - return imageSource; + + return imageSource[0]; } /** @private */ diff --git a/src/lib/CanvasAnnotationDisplay.js b/src/lib/CanvasAnnotationDisplay.js index 437f9cfe5..673e492f4 100644 --- a/src/lib/CanvasAnnotationDisplay.js +++ b/src/lib/CanvasAnnotationDisplay.js @@ -22,7 +22,8 @@ export default class CanvasAnnotationDisplay { this.context = context; if (this.resource.svgSelector) { this.svgContext(); - } else if (this.resource.fragmentSelector) { + } + if (this.resource.fragmentSelector) { this.fragmentContext(); } } -- GitLab