From 2f6b43796b434067bfbb45e73e1a6e20dcae4290 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Tue, 26 Jul 2022 11:26:27 +0200 Subject: [PATCH] Robustify image loading --- UI/Base/Img.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/UI/Base/Img.ts b/UI/Base/Img.ts index 79839183b..ecaf09abd 100644 --- a/UI/Base/Img.ts +++ b/UI/Base/Img.ts @@ -23,7 +23,13 @@ export default class Img extends BaseUIElement { if (Utils.runningFromConsole) { return source; } - return `data:image/svg+xml;base64,${(btoa(source))}`; + try{ + return `data:image/svg+xml;base64,${(btoa(source))}`; + }catch (e){ + console.error("Cannot create an image for", source.slice(0, 100)) + console.trace("Cannot create an image for the given source string due to ", e) + return "" + } } static AsImageElement(source: string, css_class: string = "", style = ""): string {