Fix thumbnail generation when offscreen canvas fails (#9272)
parent
f67b8d0d32
commit
b1cecccb57
|
@ -92,9 +92,8 @@ export async function createThumbnail(
|
||||||
context.drawImage(element, 0, 0, targetWidth, targetHeight);
|
context.drawImage(element, 0, 0, targetWidth, targetHeight);
|
||||||
|
|
||||||
let thumbnailPromise: Promise<Blob>;
|
let thumbnailPromise: Promise<Blob>;
|
||||||
|
if (canvas instanceof window.OffscreenCanvas) {
|
||||||
if (window.OffscreenCanvas) {
|
thumbnailPromise = canvas.convertToBlob({ type: mimeType });
|
||||||
thumbnailPromise = (canvas as OffscreenCanvas).convertToBlob({ type: mimeType });
|
|
||||||
} else {
|
} else {
|
||||||
thumbnailPromise = new Promise<Blob>(resolve => (canvas as HTMLCanvasElement).toBlob(resolve, mimeType));
|
thumbnailPromise = new Promise<Blob>(resolve => (canvas as HTMLCanvasElement).toBlob(resolve, mimeType));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue