<div id="images" class="owl-carousel">
<a href="/src/img_1.jpg" data-fancybox="images">
<img src="/thumb/img_thumb_1.jpg">
</a>
<a href="/src/img_2.jpg" data-fancybox="images">
<img src="/thumb/img_thumb_2.jpg">
</a>
<a href="/src/img_3.jpg" data-fancybox="images">
<img src="/thumb/img_thumb_3.jpg">
</a>
..................................
</div>
<div id="group" class="owl-carousel">
<a href="/src/img_4.jpg" data-fancybox="group">
<img src="/thumb/img_thumb_4.jpg">
</a>
<a href="/src/img_5.jpg" data-fancybox="group">
<img src="/thumb/img_thumb_5.jpg">
</a>
<a href="/src/img_6.jpg" data-fancybox="group">
<img src="/thumb/img_thumb_6.jpg">
</a>
..................................
</div>
$("#images").owlCarousel({
loop:true,
items: 5,
onInitialized : addFancy
});
$("#group").owlCarousel({
loop:true,
items: 3,
onInitialized : addFancy
});
function addFancy(event) {
var element = event.target;
var id = $(element).attr('id');
$(element).find(".owl-item.cloned a").each(function(indexCloned) {
var $clonedElem = $(this);
var link = $clonedElem.attr('href');
$clonedElem.attr('data-fancybox-trigger', id);
$clonedElem.attr('href', 'javascript:;');
$clonedElem.removeAttr('data-fancybox');
$(element).find(".owl-item:not(.cloned) a").each(function(indexReal) {
if (link === $(this).attr('href')){
$clonedElem.attr('data-fancybox-index', indexReal);
}
});
});
}
$('[data-fancybox]').fancybox({
protect: true //пример
});