Code modification help!

Need some help modifying the code in the image gallery attached pls.
I want to add a dynamic button link to the loaded images, targeting urls which are referenced in the XML file called “link”.

Appreciate any help.

Cheers
Dax