Hi guys,
I want to change a SVG image inserted via URI
First I manually inserted an image in the SVG editor (svg-editor/elements/Image/Load image file).
The selected SVG document is then encoded in Base64 and inserted into the file.
I now want to exchange the Base64 encoded text via the payload.
I think it is the same question as in this case (link), but the solution is not explained here.
I am grateful for any help!
[
{
"id": "a89f237b52c25e02",
"type": "file in",
"z": "a12c90d1b9eca540",
"name": "",
"filename": "Z:/SVG-Bilder/forum/blue_square.svg",
"filenameType": "str",
"format": "utf8",
"chunk": false,
"sendError": false,
"encoding": "none",
"allProps": false,
"x": 390,
"y": 1560,
"wires": [
[
"50d555cec4e8e40b"
]
]
},
{
"id": "9be092b39f3444f8",
"type": "inject",
"z": "a12c90d1b9eca540",
"name": "square",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 150,
"y": 1560,
"wires": [
[
"a89f237b52c25e02"
]
]
},
{
"id": "50d555cec4e8e40b",
"type": "base64",
"z": "a12c90d1b9eca540",
"name": "",
"action": "",
"property": "payload",
"x": 720,
"y": 1560,
"wires": [
[
"9031bd7ee6b7a72a"
]
]
},
{
"id": "9031bd7ee6b7a72a",
"type": "function",
"z": "a12c90d1b9eca540",
"name": "replace_picture_in_svg_block",
"func": "var pictureBase64 = msg.payload;\n\nlet svg_code = \"data:image/svg+xml;base64,\" + pictureBase64;\n\nmsg.payload = { command: \"update_attribute\",\n elementId: \"e1_image\",\n selector: \"e1_image\",\n attributeName: \"xlink:href\",\n attributeValue: svg_code\n}\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 950,
"y": 1560,
"wires": [
[
"d98bfe586c907b77"
]
]
},
{
"id": "5e53df8113abf61a",
"type": "file in",
"z": "a12c90d1b9eca540",
"name": "",
"filename": "Z:/SVG-Bilder/forum/red_circle.svg",
"filenameType": "str",
"format": "utf8",
"chunk": false,
"sendError": false,
"encoding": "none",
"allProps": false,
"x": 380,
"y": 1620,
"wires": [
[
"50d555cec4e8e40b"
]
]
},
{
"id": "e7ad919a48a6ec40",
"type": "inject",
"z": "a12c90d1b9eca540",
"name": "star",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 150,
"y": 1620,
"wires": [
[
"5e53df8113abf61a"
]
]
},
{
"id": "eefe3142503c08a9",
"type": "file in",
"z": "a12c90d1b9eca540",
"name": "",
"filename": "Z:/SVG-Bilder/forum/yellow_star.svg",
"filenameType": "str",
"format": "utf8",
"chunk": false,
"sendError": false,
"encoding": "none",
"allProps": false,
"x": 390,
"y": 1680,
"wires": [
[
"50d555cec4e8e40b"
]
]
},
{
"id": "30d83d52e5904087",
"type": "inject",
"z": "a12c90d1b9eca540",
"name": "circle",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 150,
"y": 1680,
"wires": [
[
"eefe3142503c08a9"
]
]
},
{
"id": "d98bfe586c907b77",
"type": "ui_svg_graphics",
"z": "a12c90d1b9eca540",
"group": "2f833989e5035c59",
"order": 1,
"width": "32",
"height": "16",
"svgString": "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0\" y=\"0\" height=\"100\" viewBox=\"0 0 100 100\" width=\"100\" preserveAspectRatio=\"xMidYMid meet\"><rect id=\"svgEditorBackground\" x=\"0\" y=\"0\" width=\"100\" height=\"100\" style=\"fill: none; stroke: none;\"/>\n<!-- Add here your SVG shapes (circles, rectangles, ...) -->\n<!-- Or remove everything, if you want to paste an entire drawing (<svg...>...</svg>).-->\n<image x=\"83.22237186401146\" y=\"31.890812898289198\" width=\"22.270306710809464\" height=\"31.4982\" id=\"e1_image\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wMDA7ZmlsbC1ydWxlOmV2ZW5vZGQ7c3Ryb2tlLXdpZHRoOjAuMjY0NTgzIgogICAgICAgaWQ9InBhdGgxMiIKICAgICAgIGN4PSIxMjkuNjQ1ODMiCiAgICAgICBjeT0iMTIzLjU5ODIxIgogICAgICAgcng9IjI5Ljg2MDExNyIKICAgICAgIHJ5PSIyNy41OTIyNiIgLz4KICA8L2c+Cjwvc3ZnPgo=\"/></svg>",
"clickableShapes": [],
"javascriptHandlers": [],
"smilAnimations": [],
"bindings": [],
"showCoordinates": false,
"autoFormatAfterEdit": false,
"showBrowserErrors": false,
"showBrowserEvents": false,
"enableJsDebugging": false,
"sendMsgWhenLoaded": false,
"noClickWhenDblClick": false,
"outputField": "payload",
"editorUrl": "//drawsvg.org/drawsvg.html",
"directory": "",
"panning": "disabled",
"zooming": "disabled",
"panOnlyWhenZoomed": false,
"doubleClickZoomEnabled": false,
"mouseWheelZoomEnabled": false,
"dblClickZoomPercentage": 150,
"cssString": "div.ui-svg svg{\n color: var(--nr-dashboard-widgetColor);\n fill: currentColor !important;\n}\ndiv.ui-svg path {\n fill: inherit;\n}",
"name": "",
"x": 1220,
"y": 1560,
"wires": [
[]
]
},
{
"id": "2f833989e5035c59",
"type": "ui_group",
"name": "test",
"tab": "80f0e178.bbf4a",
"order": 1,
"disp": true,
"width": "32",
"collapse": false,
"className": ""
},
{
"id": "80f0e178.bbf4a",
"type": "ui_tab",
"name": "Home",
"icon": "dashboard",
"order": 1,
"disabled": false,
"hidden": false
}
]