OL Learn

Currently used background image into variable


#1

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

Thanks

Ol


#2

How is your background image inserted into the Template?

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


#3

You can use a script:

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

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.