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; } ```