0

I have a question regarding jquery fancybox .

My code in load():

$(".fanciogallery").on("click", function(e){
    e.preventDefault();
    var gid = $(this).data("gid");

    var fancyarray = [];
    //already have an array with the infos
    gallery_array[gid].forEach(function(element){
        var impa = uploadfold + gid + '/immages_' +  element.id_img + '.png';
        //fill an array to pass to fancybox
        fancyarray.push(
            {href : impa, title : 'Title'}                                                           
        );
    });

    $.fancybox.open(
            fancyarray,
            {
                //options
                loop : false
            },
    );
  });

I am doing some testing so it's not complete or refined. I get "The requested content cannot be loaded" but it seems to get the number of elements right.

I get this error even if I hardcode a valid imagepath into

href:

probably I am filling the array wrong, the documentation it's not clear for me. Do you know what I am doing wrong?

Thank you

barbsan
  • 3,418
  • 11
  • 21
  • 28

1 Answers1

0

Check samples from documentation - http://fancyapps.com/fancybox/3/docs/#api -

$.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
});

Basically, replace href with src

Janis
  • 8,593
  • 1
  • 21
  • 27