Images and saved HTML

    Choose how an image belongs to your document before inserting it. The native image workflow supports an internet address, a path relative to BaseUrl, or an explicitly selected local file. Alternative text, tooltip, alignment, optional dimensions, aspect locking and border properties are edited together.

    Embedded SpiceLogic image selected with actual resize handles beside a formatted service table in the Avalonia editor.
    Embedded SpiceLogic image selected with actual resize handles beside a formatted service table in the Avalonia editor.

    Keep paths or embed bytes

    A local or relative authored src remains that path in body/document exports, selection HTML, source mode and Undo/Redo. Validated raster bytes supply private display transport without replacing the saved source. Your application must deliver the referenced files when the HTML moves.

    Choose the explicit base64 option when the exported HTML should carry the image. It writes a real data URI into authored HTML and is subject to the document size limit. A large data URI is shown compactly in the dialog without truncating the saved value.

    editor.BaseUrl = @"C:\Documents\Images";
    editor.DisableLocalResourceSelection = false;
    editor.EmbedLocalImageAsBase64 = false;

    Authorize local resources

    Configure an existing file base folder for implicit relative resolution. Traversal and links leaving that root are rejected. Files outside it require explicit user selection. Browse and import are offered for local source modes; a relative HTTPS base permits address entry, not local browsing. Import is explicit and atomic. Overwrite is a separate choice; opening or cancelling image properties performs no import.

    Bounded raster validation

    Selected/imported PNG, JPEG, GIF, BMP and WebP files are decoded by their actual format, not filename extension. Validation rejects corrupt/truncated data and limits encoded bytes to 8 MiB, a canvas to 16 million pixels, animation to 128 frames and total frame pixels to 64 million. Explicit embedding must also fit the one-million-character document limit.

    Online and offline behavior

    AllowExternalResources is false by default. Implicit HTTPS-base hydration requires it to be enabled. Applying an explicit image URL authorizes that selection's bounded fetch; accepted bytes remain available within the control for offline redisplay after source reload or browser recreation. Disabling resources does not start a new request. Scriptable SVG data, active schemes and protocol-relative sources are rejected.

    Display transport and Office paste

    Validated document rasters display through data/blob transport. The browser does not fetch raw HTTPS raster or CSS image URLs. Native bounded HTTPS hydration follows BaseUrl and resource policy; an explicit accepted URL selection may supply cached bytes for offline redisplay. Recognized CSS url(...) and legacy backgrounds are projected without replacing authored paths. Quoted image-set(...) remains authored but blocked and unprojected.

    Embed local images or prepare email

    Bulk embedding converts authorized local IMG sources in one Design undo operation, retaining dimensions, alternative text and surrounding content. Source is a no-op; read-only and Preview reject mutation. Existing data and remote image sources remain unchanged. The email operation applies a pending Source draft and returns an unsent message with formatted text, an HTML alternate view and validated local or embedded raster linked resources. It does not send mail. Dispose the returned message after use.

    await editor.Content.EmbedLocalImagesAsBase64Async();
    using var message = await editor.Content.GetEmailMessageWithLocalImagesEmbeddedAsync();

    Both operations honor BaseUrl and local-selection policy. Missing or denied optional local files retain their paths. Cancellation, changed document ownership, excessive image bytes or excessive resulting HTML rejects the operation; imported paths create no new filesystem or network permission.

    Last updated on Oct 18, 2026

    Put this into practice.

    Start with the C# Avalonia sample. Restore this edition's package and install the native browser prerequisites before running it.

    Prefer a guided look? Book a free live demo with our engineers - live on Zoom or Teams, never a chatbot.