Galleria plugin: How to add links?
Asked Answered
A

2

6

I´m talking about this Galleria plugin. Maybe this is too simple, but I can´t find anything in the documentation page: I have this galleria implementation. I want to add a different link to every image, so that the user can click on some image and go somewhere. How can I do that? Or where to find the answer?

Artifice answered 15/3, 2011 at 23:56 Comment(0)
W
14

Another option is to give the URL that you want to link to in the longdesc attribute of your IMG tag, like this:

<img src="mypic1.jpg" longdesc="http://www.amazon.co.uk" >
<img src="mypic2.jpg" longdesc="http://www.google.com" >

The Galleria code will automatically create a link from the longdesc URL if you supply one. This is a documented feature, but it is rather tucked away.

Warrantable answered 19/9, 2011 at 21:0 Comment(1)
Gaaaah... Thank you so much. I was scratching my head hardcore until I found your answer. Galleria's author really needs to document that better.Placket
C
2

You can also define the images as a JSON array:

 <script>
  var data = [
    {
        image: 'img1.jpg',
        thumb: 'thumb1.jpg',
        title: 'my first image',
        description: 'Lorem ipsum caption',
        **link**: 'http://domain.com'
    },
    {
        image: 'img2.jpg',
        thumb: 'thumb2.jpg',
        title: 'my second image',
        description: 'Another caption',
        link: '/path/to/destination.html'
    }
];

$('#container').galleria({
    data_source: data
});
</script>

see link property above.

Carrnan answered 16/3, 2011 at 1:23 Comment(1)
data_source also can be dataSource, see galleria.aino.se/docs/1.2/references/dataHudgins

© 2022 - 2024 — McMap. All rights reserved.