OL Learn

Currently used background image into variable


Is it possible to get the information of the currently used section background image and output into a text box?




How is your background image inserted into the Template?

Datamapper input?
Dynamically called images?
Static image from Template?


You can use a script:

var bg = merge.template.contexts.PRINT.sections['SECTIONNAME'].background.url.split("/");
var result = bg[bg.length - 1];

Because background.url will give you the whole url/path (internal source: images/myBackground.pdf ; external source: file:///C:/myFolder/myBackground.pdf), you have to cut it. I prefer the way to split the path into an array based on slash ( / ) and just use the last value/index of the array (filename).

Hope that helps.