Developer forum

Forum » Templates » The Gallery module - adding the tag

The Gallery module - adding the tag

Morten Sigh
Reply

I want to display the meta data title added in the File archive, so the gallery displays that instead of the filename when the large image is shown. I'm using the tag <!--@Gallery.Image.Metadata.title--> and the standard LightboxBorder.html but I guess I have to change something in the lightbox.js but I can't find the right place for the tag...

Anyone with a little javascript help?


Replies

 
Mikkel Ricky
Reply
This post has been marked as an answer

Where do you use <!--@Gallery.Image.Metadata.title-->? If you just use it in the title attribute (if it's defined) then it will be used as the lightbox title:

<a href="<!--@Gallery.Image.Thumb.Large.Path-->" rel="lightbox[img]" title="<!--@If Defined(Gallery.Image.Metadata.title)--><!--@Gallery.Image.Metadata.title--><!--@Else--><!--@Gallery.Image.Name--><!--@EndIf-->"

Otherwise, you can add it to a custom data attribute

<a href="<!--@Gallery.Image.Thumb.Large.Path-->" rel="lightbox[img]" title="<!--@Gallery.Image.Name-->" data-metadata-title="<!--@If Defined(Gallery.Image.Metadata.title)--><!--@Gallery.Image.Metadata.title--><!--@EndIf-->">

and then change lightbox.js to use the data-metadata-title attribute if it's non-empty and use the title attribute otherwise. 

In lightbox.js you have to change the line

this.imageArray.push([imageLink.href, imageLink.title]);

to

// Use data-metadata-title attribute as title if set. Otherwise, use title attribute
this.imageArray.push([imageLink.href, imageLink.getAttribute('data-metadata-title') ? imageLink.getAttribute('data-metadata-title') : imageLink.title]);

and change the line

return [anchor.href, anchor.title];

to

return [anchor.href, anchor.getAttribute('data-metadata-title') ? anchor.getAttribute('data-metadata-title') : imageLink.title];

I hope it makes sense.

Best regards,
Mikkel

Votes for this answer: 1
 
Morten Sigh
Reply

Perfect! Thanks....

 

You must be logged in to post in the forum