Docly Developers
Function API only Updated 30 May 2026

extractAndEmbedBase64Images(filePath, [propertyFilter])

This function extracts images encoded in base64 from HTML properties of a document. It then converts these images to a more storage-efficient format by saving them as embedded files within the document. The revised HTML will reference these images using a Content ID (CID) mechanism, similar to how images are referenced in email attachments.

See also Path traversal

Parameters

filePathstringrequired

The absolute path to the document where images will be extracted and embedded.

propertyFilterstringoptional

Specifies which properties to scan for base64 images. Use "*" (default) to scan all properties, or provide a specific property name.

The function recursively searches through objects and arrays to find matching properties. Supports wildcards.

Returns

A number indicating the total count of base64 image references that were successfully extracted and updated to CID format in the document.

Example

Normal JavaScript, running in the browser or on the Docly™ server.
let result = docly.extractAndEmbedBase64Images(filePath);
return result;