$(document).ready(function() { $('div.description img').each(function() { var a = $(this).parent(); if(a[0].tagName != "A") { $(this).wrap(""); } }); $("a[rel=lightbox]").fancybox({ 'transitionIn' : 'fade', 'transitionOut' : 'none', 'titlePosition' : 'over', 'opacity' : 'true', 'titleFormat' : function(title, currentArray, currentIndex, currentOpts) { return 'Obrázok ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? '   ' + title : '') + ''; } }); });