Image file viewer

Home > Basic examples > Example 15

Explanation

If the local file to be registered is an image file, a viewer is provided for previewing the target file.

The default settings are that the image are displayed on the pop-up window by using the built-in viewer. Using the event method, the developer can make the desired preview screen directly.

// Set to true to view images.
dx.setPreviewEnable(true);

// Set the background color. 
dx.setPreviewBackgroundColor("#ff0000");

// Set to 1 to run the built-in viewer, set to 2 to provide event. 
dx.setPreviewMethod(1);

// Set the order value of the item to be previewed as parameter to preview. 
dx.preview(0);

// For the event method, the onDX5Preview callback function is called when the preview function is called.
function onDX5Preview(id, itemIndex, itemId, itemSource) {
	if (itemSource) {
		...
		img.src = itemSource;
	}
}

Example

Only local files can be previewed.

Preview