简体   繁体   中英

Galleria plugin: How to add links?

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?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM