How to open fancybox with array of images

前端 未结 1 1529
借酒劲吻你
借酒劲吻你 2021-01-15 16:30

i have an array of images ulrs in JS:

photos= [\'img1.jpg\',\'img2.jpg\',...]

I\'m using Fancybox 2.

How can I open fancybox with t

相关标签:
1条回答
  • 2021-01-15 17:02

    Found a solution: The photos array must be in the format:

    photos = [ {href : 'img1.jpg', title : 'Title'}, {href : 'img2.jpg', title : 'Title'} ]
    

    Then it is working.

    And the initializing is done correctly by:

    $('#start_slides').fancybox();
    
    $.fancybox.open(photos,{
        'openEffect'    :   'elastic',
        'closeEffect'   :   'elastic',
        'nextEffect'    :   'fade',
        'openSpeed'     :   600, 
        'closeSpeed'    :   200,
        helpers : {
            buttons : {}
        }
    });
    
    0 讨论(0)
提交回复
热议问题