From b1cecccb578c412b85c1d082a30fe31def090829 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 13 Sep 2022 13:34:35 +0100 Subject: [PATCH] Fix thumbnail generation when offscreen canvas fails (#9272) --- src/utils/image-media.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/utils/image-media.ts b/src/utils/image-media.ts index b768133382..1f1db27727 100644 --- a/src/utils/image-media.ts +++ b/src/utils/image-media.ts @@ -92,9 +92,8 @@ export async function createThumbnail( context.drawImage(element, 0, 0, targetWidth, targetHeight); let thumbnailPromise: Promise; - - if (window.OffscreenCanvas) { - thumbnailPromise = (canvas as OffscreenCanvas).convertToBlob({ type: mimeType }); + if (canvas instanceof window.OffscreenCanvas) { + thumbnailPromise = canvas.convertToBlob({ type: mimeType }); } else { thumbnailPromise = new Promise(resolve => (canvas as HTMLCanvasElement).toBlob(resolve, mimeType)); }