Can someone help me figure out how to use fancybox to display a series of images in a lightbox? I have this JS object called fancybox_img, and here's what it contains:
{card_173: Array(1), card_171: Array(5), card_169: Array(4)}
card_169: Array(4)
0: {src: "flat6.jpeg"}
1: {src: "flat7.jpg"}
2: {src: "flat6.jpeg"}
3: {src: "flat4.jpg"}
length: 4
__proto__: Array(0)
card_171: (5) [{…}, {…}, {…}, {…}, {…}]
card_173: [{…}]
__proto__: Object
I'm trying to select each card and display the array of images like this:
jQuery('#module_properties .item-tool').click(function() {
var idCard = jQuery(this).parents(".card").data("card");
var imgCard = fancybox_img[idCard];
jQuery.fancybox.open([
imgCard
]);
});
When I console log imgCard, it shows as an object with multiple image sources. Here's an example given by fancybox for displaying multiple images:
Example of opening image gallery programmatically (the opts are optional):
$.fancybox.open([
{
src : '1_b.jpg',
opts : {
caption : 'First caption',
thumb : '1_s.jpg'
}
},
{
src : '2_b.jpg',
opts : {
caption : 'Second caption',
thumb : '2_s.jpg'
}
}
], {
loop : false
});
I'm not sure how to structure my data to achieve the same result as {src: 'url'},{src: 'url2'}.... Any advice would be greatly appreciated. Thanks!