From 74ffd555837c362ae5198ae4f8525ce945eaa3c2 Mon Sep 17 00:00:00 2001 From: "S. Carstens" Date: Wed, 10 Aug 2022 18:41:44 +0200 Subject: [PATCH] Update images.md (#26684) --- aspnetcore/blazor/images.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/aspnetcore/blazor/images.md b/aspnetcore/blazor/images.md index f3eef0331b..781b1194fb 100644 --- a/aspnetcore/blazor/images.md +++ b/aspnetcore/blazor/images.md @@ -73,8 +73,11 @@ The example in this section streams image source data using [JavaScript (JS) int const arrayBuffer = await imageStream.arrayBuffer(); const blob = new Blob([arrayBuffer]); const url = URL.createObjectURL(blob); - document.getElementById(imageElementId).src = url; - URL.revokeObjectURL(url); + const image = document.getElementById(imageElementId); + image.onload = () => { + URL.revokeObjectURL(url); + } + image.src = url; } ``` @@ -175,8 +178,11 @@ The example in this section streams image source data using [JavaScript (JS) int const arrayBuffer = await imageStream.arrayBuffer(); const blob = new Blob([arrayBuffer]); const url = URL.createObjectURL(blob); - document.getElementById(imageElementId).src = url; - URL.revokeObjectURL(url); + const image = document.getElementById(imageElementId); + image.onload = () => { + URL.revokeObjectURL(url); + } + image.src = url; } ```