DanHobbs DanHobbs - 9 months ago 100
CSS Question

Hyperlink in Lightbox Gallery

I have a lightbox gallery here: www.hrmny.co.uk (click on portfolio)

I want it so that when a photo is clicked, the caption underneath is a hyperlink to another website.

Could someone advise on the code needed for this as the usual doesn't seem to be working for me as it seems to get rid of the title all together?

Thanks a lot

Answer Source

I have had a look at the documentation and source code for poptrox, your lightbox plugin and cannot see a convenient way to pass html to the caption in order to create the link, as it uses the contents of the image title attribute at the moment.

On line 606 of the poptrox (non-minified) code on GitHub is the line where it sets the caption text using captionText: i.attr('title'),, if you replace this with captionText: $.parseHTML(i.attr('title')),, then jQuery will parse the content of the title attribute as html instead of plain text. You also need to set the title attributes for each image to title="<a href='link/to/site'>CAPTION TITLE</a>" instead of just being CAPTION TITLE as it is now. Note the single quotation marks around the link but the double marks around the whole title attribute. You will also have to serve the modified version of poptrox from your server.