GalleryEditor API allows the user to perform different operations on the currently opened document. They are available within the Context Object, when the user is editing a Gallery.

GalleryEditor API are to be considered as a feature in progress. Changes and additions may be made without warning.

In the source code, we will refer to the Context Object as a generic "ctx" object.

activeDocument

The activeDocument is the entry point of the GalleryEditor API. It contains a set of different methods to analyze the currently opened document.

Methods of the activeDocument object

getXmlContent

Returns the complete XML content of the document.

It can be called as

ctx.activeDocument.getXmlContent(options);
Table 1. Method information

Method

getXmlContent

Parameter * Optional {object} options - An object containing optional criteria about the xml content:

  • Optional {boolean} includeInherited - if true the xml will contain inherited sections content in place of reference.

If options is not specied or if it’s an empty object the xml of the entire document will be returned.

Returns

{String} The XML document as a string.

Example
// Obtains the XML of the document.
var xml = ctx.activeDocument.getXmlContent();

// For example, we can parse the XML with jQuery and use it somehow.
var parsedXML = $.parseXML( xml );

// ...

getObjectsData

Returns an array containing the list of the data of each object present in the active document.

It can be called as

ctx.activeDocument.getObjectsData();
Table 2. Method information

Method

getObjectsData

Parameter

None

Returns

{Array} The array of data infornation of the all the objects present in the active document

The objects contained in the array are intended as "read only" objects. Any change made on them will not be reflected in the active document.

Example
// Obtains the current selection.
var objectsData = ctx.activeDocument.getObjectsData();
// objectsData is now an array of objects.

Here below an extract of the data contained in each returned object:

{
    "id": "199$1.0.624088073",
    "type": "Image",
    "name": "Official_portrait_of_Barack_Obama-U47037702204ISU-266x200@Globe-Web.jpg",
    "description": "",
    "owner": "user",
    "creator": "user",
    "created": 1457105152,
    "last_modifier": "user",
    "size": 125008,
    "system_attributes": {
        "workfolder": "",
        "template": "",
        "templateName": "",
        "summary": "",
        "wordCount": "",
        "sugCategory": "",
        "channel": "",
        "title": "...",
        "storyType": "",
        "productInfo": {
            "name": "",
            "issueDate": ""
        },
        "imageInfo": {
            "width": 266,
            "height": 200,
            "ptWidth": 63.84000015258789,
            "ptHeight": 48,
            "colorType": "RGB",
            "processTypes": ["resample"]
        },
        "priority": ""
    },
    "system_attributes_xml": "<props><process><type>resample</type></process><title>...</title><summary/><imageInfo>\n<width>266</width>\n<height>200</height>\n<ptWidth>63.84</ptWidth>\n<ptHeight>48.0</ptHeight>\n<xDim>22.52</xDim>\n<yDim>16.93</yDim>\n<dim>2.252cm x 1.693cm</dim>\n<xres>300.0</xres>\n<yres>300.0</yres>\n<colorType>RGB</colorType>\n<fileType>PNG</fileType>\n</imageInfo></props>",
    "usage_ticket": "<?xml version='1.0' encoding='UTF-8'?><tl></tl>"
}

isCroppedImage

Return a boolean value to check if the image is hard cropped.

It can be called as

ctx.activeDocument.isCroppedImage(loid);
Table 3. Method information

Method

isCroppedImage

Parameter

{String} - The loid of the image in the format: {dbId}${loid} (e.g. 199$1.0.624088073).

Returns

{Boolean} true if the image is hard cropped.

// Obtain the cropped information.
var isCropped = ctx.activeDocument.isCroppedImage(loid);

//check the isCropped variable

saveDocument

Execute the save of the current document.

It can be called as

ctx.activeDocument.saveDocument();
Table 4. Method information

Method

saveDocument

Parameter

Optional {Function} callback - A function invoked if the the document is successfully saved

If the document is not dirty, the save is not executed, but the callback, if defined, is always invoked.