Skip to main content

Common

toBase64#

app.common.toBase64(options) — Converts image files to a base64-encoded string. Use for rendering images in Connected App widgets (e.g., task before/after photos, attachments, signatures).

Returns — The base64-encoded string directly (e.g., iVBORw0KGgo...). Use with data:image/png;base64, prefix for <img src>.

note

Works only for image files.

Params — Pass exactly one:

OptionDescription
{ fileId: number }Facilio file ID to convert
{ url: string }Image download URL to convert

Example

// By URLconst base64 = await window.facilioApp.common.toBase64({ url: 'https://example.com/image.png' });document.querySelector('img').src = `data:image/png;base64,${base64}`;
// By file ID (e.g., from record attachment or signature field)const base64 = await window.facilioApp.common.toBase64({ fileId: 1234 });document.querySelector('img').src = `data:image/png;base64,${base64}`;
On This Topic