Open file preview

Open the platform's file preview lightbox

Opens the platform's file preview (lightbox) for one or more files. The preview UI natively renders next/prev navigation across the array.

Parameter

ParameterTypeDescription
argsObjectPreview configuration. See the properties listed below.

The args object accepts the following properties:

PropertyTypeDescription
filesObject[]Array of file metadata objects to preview. Pass a single-element array for single-file fields.
indexOfFileNumberIndex of the file to open the preview on (default: 0).

Syntax

kf.client.openFilePreview(args).then(() => {...})

or

await kf.client.openFilePreview(args);

Returns

Returns a promise that resolves once the user closes the preview.

Example

To preview a single image field value.

await kf.client.openFilePreview({ files: [imageFieldValue] });

To preview a multi-file attachment field, opening on the third file.

await kf.client.openFilePreview({ files: attachmentFieldValue, indexOfFile: 2 });

On this page