Media library
The media library keeps the pictures a dashboard shows — the Image widget’s source, the logo and dark logo — in the Node-RED user directory, so they are uploaded once, picked from a grid of thumbnails and never leave the machine.
Opening it
Section titled “Opening it”The library is part of the builder (it needs the Node-RED editor that opened the dashboard window):
- A widget: select an Image widget and press the image button next to its source field.
- The logos: Dashboard settings ▸ Appearance ▸ the image button next to Logo (or Logo for dark theme).
A picked image is stored as media/<name>: relative to the dashboard, so the value survives a rename of the dashboard’s path. The text field stays editable, so a path served by Node-RED or an http(s) address keeps working.
Upload: drop files on the dialog or use its upload button. A tile’s buttons rename the file in place (the extension stays: it is the type of the file) and delete it in two steps. A name that is taken, or that the store would refuse, is offered as the next free one instead of failing.
Types and size
Section titled “Types and size”PNG, JPEG, WebP, GIF and SVG. The content decides the type, not the name: a PNG renamed to .jpg is refused, as is anything that is not one of these images.
The limit is 5 MB per file unless settings.js sets another one:
tessera: { mediaMaxSize: 10 * 1024 * 1024, // bytes},A file over the limit is refused before it is stored (413) and the dialog says so.
SVG is sanitised on upload
Section titled “SVG is sanitised on upload”Media is served from the dashboard’s own origin, so an SVG is executable content: a <script> in it would be stored XSS. Every SVG goes through an allowlist sanitiser before it reaches the disk, and only the sanitised document is stored and served. Dropped:
<script>,<style>,<foreignObject>,<metadata>,<handler>,<listener>and the animation elements (<animate>,<animateMotion>,<animateTransform>,<set>,<discard>), with everything inside them.- every
on*attribute (onload,onclick, …). javascript:,vbscript:anddata:text/htmlvalues.href/xlink:href/srcthat are not a#same-documentreference or an embeddeddata:image/PNG, JPEG, GIF or WebP.- an external
url(…)infill,stroke,filter,clip-path,maskormarker-*, and anystyledeclaration with a CSS escape or a comment (both can smuggle one past a reader).
An unknown element is unwrapped, not deleted: a <a> (link) loses the link and keeps its text, and an element from another namespace keeps its visible children. Text, shapes, gradients and filters of the SVG spec survive. A file that is not a well-formed SVG is refused (415) rather than cleaned.
The stored SVG is served with Content-Security-Policy: default-src 'none'; script-src 'none', X-Content-Type-Options: nosniff and a sandbox policy, so opening the file directly shows the picture and runs nothing.
Where the files are
Section titled “Where the files are”<userDir>/tessera-media/, next to flows.json: userDir is ~/.node-red by default, or what node-red -u / userDir in settings.js says. One folder per Node-RED, shared by every dashboard on it — the names are the library’s, so deleting a file that a dashboard still shows leaves a broken image there.
They are served by the runtime at /<path>/media/<name>, where <path> is the dashboard’s (Dashboard settings ▸ the path of the app node, tessera by default), with Cache-Control: no-cache, an ETag and the type of the extension: a rename or a delete is seen on the next load, and nothing is fetched from a third party (dashboards often run offline).
Nothing is content-hashed, so the URL is stable: a media/<name> in a flow, in a template or in custom CSS keeps working as long as the name does.
For scripts
Section titled “For scripts”The builder talks to four admin endpoints, under the admin root (httpAdminRoot, / by default), all requiring the flows.write permission (the same as editing flows):
| Request | What it does |
|---|---|
GET <adminRoot>/tessera/media |
the list: [{ name, size, type, modified, url }], url relative to the dashboard (media/<name>) |
POST <adminRoot>/tessera/media/<name> |
upload: the body is the file itself, not a form and not base64 |
POST <adminRoot>/tessera/media/<name>/rename?to=<new name> |
rename, keeping the extension |
POST <adminRoot>/tessera/media/<name>/delete |
delete |
The answers are 201 (upload), 200 (list, rename), 204 (delete), 400 (a name outside ^[A-Za-z0-9][A-Za-z0-9_-]{0,63}\.[A-Za-z0-9]{1,5}$), 404 (no such file), 409 (the name exists: nothing is overwritten), 413 (over the size limit) and 415 (a type or content the store does not take). Errors are { "error": "…" }.
Writes are atomic (a temporary file and a hard link), so a failed upload or a rename that cannot finish leaves the folder as it was.
Alternatives
Section titled “Alternatives”A URL still works everywhere a media value does, and may be simpler for one file:
// settings.js: /home/pi/static/images/plan.png is served as /images/plan.pnghttpStatic: '/home/pi/static',The library is the better default: no settings.js edit, no restart, uploads from the browser, and the SVG sanitiser.