Currently I use this code for apply Fancybox to a set of images not wrapped by tag <A>
:
$("img[alt=lightbox]").each(function(){
$(this).fancybox({ href : $(this).attr('src') });
});
Now I'd like to add to the same group all images added in this way.
I tried with:
$("img[alt=lightbox]").each(function(){
$(this).attr("data-fancybox-group", "gallery");
$(this).fancybox({ href : $(this).attr('src') });
});
Without luck, do you have any advice?
The answer for this question Fancybox gallery without a href? was written for fancybox v1.3.4.
The same solution would work equally for fancybox v2.x, however bear in mind that fancybox v2.x API options are new and not compatible with previous versions ... so you have actually to upgrade the API options to make it work with v2.x
Here is the v2.x update :
The basic html :
... notice that we used the (HTML5)
data-*
(data-href
) attribute to target the big images and let thesrc
attribute to target the thumbnails.Then the js :
And of course, here is the DEMO
According to fancy box:
Look at bottom of page here
So try setting the rel: