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?

bkaid
  • 51,465
  • 22
  • 112
  • 128
Edgar
  • 61
  • 1
  • 2

2 Answers2

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.

Victoria
  • 436
  • 5
  • 16
  • 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. – aendra Oct 02 '12 at 15:49
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.

anazimok
  • 1,750
  • 2
  • 20
  • 33
  • data_source also can be dataSource, see http://galleria.aino.se/docs/1.2/references/data/ – L42y Dec 08 '11 at 05:47