From 16f69cda316cf55810194b967cc78d669272ba4b Mon Sep 17 00:00:00 2001 From: Mattias Persson Date: Fri, 11 Oct 2024 16:03:51 +0200 Subject: [PATCH] Fix picture elements add new image --- src/lib/Modal/PictureElements/konvaEditor.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/lib/Modal/PictureElements/konvaEditor.ts b/src/lib/Modal/PictureElements/konvaEditor.ts index 35e7e97b..99283bab 100644 --- a/src/lib/Modal/PictureElements/konvaEditor.ts +++ b/src/lib/Modal/PictureElements/konvaEditor.ts @@ -1866,7 +1866,7 @@ export class KonvaEditor extends KonvaBase { * Add image */ public async addImage() { - const src = '/favicon.png'; + const src = 'https://demo.home-assistant.io/stub_config/t-shirt-promo.png'; try { const image = await this.loadImage(src); @@ -1884,6 +1884,22 @@ export class KonvaEditor extends KonvaBase { this.handleAddNode(node); } catch (err) { console.error('error adding image:', err); + + // add empty fallback + const node = new Konva.Image({ + type: 'image', + name: 'Image', + image: undefined, + src: src, + width: 100, + height: 100, + draggable: true + }); + + this.handleAddNode(node); + + // gray box onerror + await this.updateImage(node, src, false); } }