jQuery(document).ready(function($) { $.getJSON("data.json", function(data) { for (i of data) { if (i.photo == "ok" || i.photo == "good") { paintingHtml = '' paintingHtml += ''; $("#gallery").append(paintingHtml); } } $('[data-fancybox="exposition"]').fancybox( { infobar: false, toolbar: true, smallBtn: false, buttons: ["arrowLeft", "arrowRight", "close"], arrows: false, transitionEffect: "fade", baseClass: 'fancybox-custom-layout', mobile: { preventCaptionOverlap: true, }, caption: function(instance, item) { var idx = item.opts.fancyboxIndex - 1; // painting number if (item.opts.fancyboxIndex >= 1000) idx = item.opts.fancyboxIndex - 1000 + 383 - 1; // inédit: index starts at 1000 // 383: total number of paintings except inédit return '\
\ ℹ︎\ ' + data[idx].title + '' + (data[idx].month != '—' ? data[idx].month + ' ' : '') + data[idx].year + '\ ' + data[idx].paint + ' sur ' + data[idx].support.toLowerCase() + ' (' + data[idx].dimension + ')\ ' + data[idx].comment + '\
\ '; } }); }); });