Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Fix thumbnail generation when offscreen canvas fails (#9272)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy committed Sep 13, 2022
1 parent f67b8d0 commit b1ceccc
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/utils/image-media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,8 @@ export async function createThumbnail(
context.drawImage(element, 0, 0, targetWidth, targetHeight);

let thumbnailPromise: Promise<Blob>;

if (window.OffscreenCanvas) {
thumbnailPromise = (canvas as OffscreenCanvas).convertToBlob({ type: mimeType });
if (canvas instanceof window.OffscreenCanvas) {
thumbnailPromise = canvas.convertToBlob({ type: mimeType });
} else {
thumbnailPromise = new Promise<Blob>(resolve => (canvas as HTMLCanvasElement).toBlob(resolve, mimeType));
}
Expand Down

0 comments on commit b1ceccc

Please sign in to comment.