Variable backgrounds from data file

I have a data file with 2 columns

Name, backgroundpath
Mark, c:\picture\path\image1.jpg

There are 75 records with 75 different images to use. How can I use this to change background for each record?

Hi Mark,

What you need to do is add a image to your template using the Insert Image. Select from disk and browse to the image. Once the image is in your template you can right click it and select Convert to Absolute if you want it absolutely positioned. Right click the image again and select Dynamic Image.

(I will now explain how I went about this. But all you really need now is the script below. Read further to see why.)

This will open a script window. In the Prefix box you should see a string something like this.

file:///C:/Users/UserName/Pictures/

Delete only this portion from the prefix.

C:/Users/UserName/Pictures/

In the Filed column select your data’s Path field. And in the Suffix column delete all its contents. Before clicking OK first we need to convert your Path field string to suit Connect. So click Expand to convert the script to a real script. You will see the code that is actually happening with this dynamic script. Delete all the code and replace it with mine.

var path, newPath, result = "";

path = record.fields["path"];
newPath = path.replace(/\\/g,"/");
if (path !== "") {
	result += "file:\/\/\/" + newPath;
}

if (result !== "") results.attr("src", result);

You will need to change the following line in the code to use the name of your mapped path field.

Change:
record.fields["path"];

To:
record.fields["backgroundpath"];

Just a reminder. You will need to select Preview tab in the designer and then cycle through your data to see the images change.

Regards
S