ImageResource

The ImageResource object represents an image resource in a template.

In script, an ImageResource is retrieved via the images Array which contains a list of all image resources that are included in the current template (see template).
For example: var myImage = merge.template.images[0];.

Functions and fields

Field

Type

Description

modified

Number

Timestamp of the last modification of the image resource, for example: 1566660504000.

name

String

The base name of the image resource, for example: "cat.jpg".

path

String

The path of the image resource, relative to the template, for example: "images/cat.jpg".

Example

The following script adds an image called 'dog.jpg' to the content of the template if the image can be found in the template's resources:

Copy
const image = merge.template.images.find(image => image.name == 'dog.jpg'); 
if (image) {    
    results.after(`<img src=${image.path}>`);
}