Answer the question
In order to leave comments, you need to log in
How to apply lightbox to all image links?
Hello!
Here in Fancybox , you can make the fancybox() parameter apply to all links that lead to images, in fact, like this:
jQuery(document).ready(function($){
var select = $('a[href$=".bmp"],a[href$=".gif"],a[href$=".jpg"],a[href$=".jpeg"],a[href$=".png"],a[href$=".BMP"],a[href$=".GIF"],a[href$=".JPG"],a[href$=".JPEG"],a[href$=".PNG"]');
select.attr('rel', 'fancybox');
select.fancybox();
});
lightbox.option({
'resizeDuration': 200,
'wrapAround': true
})
Answer the question
In order to leave comments, you need to log in
It will be a rather crooked implementation, but it should work.
Try to approach from the opposite. For initialization, do you need the A tag to have the data-lightbox attribute if its link leads to an image?
You do something like this:
var select = $('a[href$=".bmp"],a[href$=".gif"],a[href$=".jpg"],a[href$=".jpeg"],a[href$=".png"],a[href$=".BMP"],a[href$=".GIF"],a[href$=".JPG"],a[href$=".JPEG"],a[href$=".PNG"]');
select.each(function(index, item){
item.data("lightbox", "some text");
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question