Nodes
Image
Ein Bild, auf das Ihre Daten zeigen, oder eines, das ein Generierungs-Endpoint erzeugt.
A static image points at something you hold — a signature, a logo, a site photograph — with every field able to vary per recipient. A dynamic image describes what is wanted and leaves the endpoint to make it.
- Helper
- image
- Node-Art
- image
- Kategorie
- Medien
- Wird aufgelöst
- Both
- Kinder
- None.
| Option | Typ | Was sie bewirkt |
|---|---|---|
id erforderlich | string | Stable address for the node. Generation endpoints target it and build artifacts diff on it, so treat a rename as a breaking change. |
src erforderlich | string | (data) => string | Static only. Path or URL to the image; lands on the node as path. |
alt | string | (data) => string | Static only. Alternative text — and, while the renderers draw a frame rather than the picture, the words printed inside it. |
width | number | (data) => number | Static only. Intended width. Carried onto the node untouched; no shipped renderer reads it yet. |
height | number | (data) => number | Static only. Intended height, on the same terms as width. |
placeholder | (data, availableTokens) => string | Dynamic only. What previews show in place of generated content. Optional, but a letter that reads badly without one cannot be reviewed. |
generalPrompt erforderlich | (data, availableTokens) => string | Dynamic only. What this node should say. |
infoPrompt | (data, availableTokens) => string | Dynamic only. Context the model should have but should not restate. |
negativePrompt | (data, availableTokens) => string | Dynamic only. What to avoid — claims, tones, or facts it must not invent. |
systemPrompt | (data, availableTokens) => string | Dynamic only. Role and voice, applied ahead of the other prompts. |
derivers | DeriverInvocation[] | Values computed before the node resolves, written to derived.* and readable from a template token. Built with derive(). |
Jedes Feld nimmt eine Funktion
src, alt, width und height nehmen jeweils einen einfachen Wert oder eine
Funktion Ihrer Daten. Eine Unterschrift, die je Standort abweicht, ein Logo je
Marke, ein Foto nach Aktenzeichen — all das bleibt im Node, statt zu einer
Verzweigung im Template zu werden:
image<MemberData>({
id: "signature",
src: (data) => data.signatureUrl,
alt: (data) => `Signed by ${data.managerName}`,
width: 180,
});
Aus src wird path
Die Option heißt src; der aufgelöste Node nennt sie path. Klappen Sie Wozu
es aufgelöst wird bei der ersten Variante unten auf, um es zu sehen.
Dynamische Bilder
Ein dynamisches Bild wird beschrieben statt geliefert und nimmt dieselben vier Prompt-Slots wie ein dynamischer Absatz.
negativePrompt verdient hier seinen Platz mehr als irgendwo sonst. Generierte
Bilder scheitern auf vorhersehbare Weise — eingebackener Text, erfundene Logos,
erkennbare Gesichter — und der Slot schließt das einmalig aus, im Node.
Varianten
Static
src/nodes/image/static.node.ts A signature whose file and caption both follow the data.
import { image } from "docxcelerate";
import type { SampleData } from "../sample-data.ts";
/**
* Every field takes a plain value or a function of your data, so a signature
* that varies by manager needs no branching in the template.
*/
export const Signature = image<SampleData>({
id: "signature",
src: (data) => data.signatureUrl,
alt: (data) => `Signed by ${data.managerName}`,
width: 180,
height: 60,
}); Wozu es aufgelöst wird
Der Node, wie er im DocumentModel erscheint: das JSON, das ein Renderer bekommt. Kein Styling, kein Layout.
{
"id": "signature",
"kind": "image",
"mode": "static",
"path": "assets/signature-lindqvist.png",
"alt": "Signed by Tomas Lindqvist",
"width": 180,
"height": 60
} Dynamic
src/nodes/image/dynamic.node.ts Described rather than supplied, with the failure modes fenced off.
import { image } from "docxcelerate";
import type { SampleData } from "../sample-data.ts";
/**
* The same prompt set as a dynamic paragraph, for artwork the endpoint
* produces rather than something you hold. The placeholder is what previews
* show, so the layout is settled before any image exists.
*/
export const CentrePhoto = image<SampleData>({
id: "centre-photo",
placeholder: (data) => `Photograph of ${data.centreName}`,
generalPrompt: (data) =>
`A wide daylight photograph of the entrance to ${data.centreName}, ` +
`people arriving, no text overlay.`,
negativePrompt: () => `No logos, no recognisable faces, no stock-photo staging.`,
}); Wozu es aufgelöst wird
Der Node, wie er im DocumentModel erscheint: das JSON, das ein Renderer bekommt. Kein Styling, kein Layout.
{
"id": "centre-photo",
"kind": "image",
"mode": "dynamic",
"placeholder": "Photograph of Riverside Leisure Centre"
} Was der Endpoint gefragt wird
Gegen dieselben Beispieldaten aufgelöst. Ein Vorschau-Build hält beim Platzhalter an; ein Build zur Anfragezeit schickt diese mit.
- general
- A wide daylight photograph of the entrance to Riverside Leisure Centre, people arriving, no text overlay.
- negative
- No logos, no recognisable faces, no stock-photo staging.
Anmerkungen
- Der Node hält einen Pfad, nie die Bytes. Während eines Builds wird nichts geladen und nichts geprüft; ein kaputter Pfad scheitert beim Rendern.
altlohnt sich auch, solange die Renderer nur Rahmen drucken — denn der Rahmen drucktalt.