Skip to main content

imageUploadUrl

Description

Optional. Specifies the URL which will be used for image upload (from the toolbar, menubar, clipboard paste, or drag-and-drop)

When the property is set, RichText uploads each inserted image to the given endpoint and inserts the URL returned by the server.

When the property is omitted or set to a falsy value ("", null, undefined), RichText switches to inline mode: the image file is read on the client and embedded directly into the content as a base64 data URL — no server is required. Inline images larger than 1024×800 are proportionally downscaled to fit within these limits.

note

Inline (base64) images are not preserved by the built-in DOCX / PDF export. If you rely on export, supply an imageUploadUrl so that images reference an external location.

caution

Base64 encoding increases the encoded payload by roughly one third relative to the original file. A document with several large inline images grows accordingly, which affects the size of the value returned by getValue(), the memory footprint of the editor, and the cost of persisting or transferring the content. Prefer a server imageUploadUrl for documents that contain many or large images.

Usage

imageUploadUrl?: string;

Example

Upload images to a server endpoint:

// initialize RichText
new richtext.Richtext("#root", {
imageUploadUrl: "https://example.com/upload"
// other configuration properties
});

Insert images inline as base64 (no server required) — omit the property or pass an empty string:

new richtext.Richtext("#root", {
// imageUploadUrl is not set, images are inserted as base64 data URLs
// other configuration properties
});

Change log: The property was added in v2.0. Starting with v2.1, the property is optional: when omitted, images are inserted inline as base64 data URLs.

Related articles: Configuration, Working with the server

Related sample: RichText. Initialization