Advertisement
Guest User

magnificPopup Retina lightbox add-on

a guest
May 24th, 2025
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.     if (typeof $.fn.magnificPopup === 'function') {
  3.         var lightboxgallerygroups = {};
  4.         $('.portfolio-box [data-group], .gallery-box [data-group]').each(function () {
  5.             var id = $(this).attr('data-group');
  6.             if (!lightboxgallerygroups[id]) {
  7.                 lightboxgallerygroups[id] = [];
  8.             }
  9.             lightboxgallerygroups[id].push(this);
  10.         });
  11.  
  12.         $.each(lightboxgallerygroups, function () {
  13.             $(this).magnificPopup({
  14.                 type: 'image',
  15.                 closeOnContentClick: true,
  16.                 closeBtnInside: false,
  17.                 gallery: { enabled: true },
  18.                 image: {
  19.                     src: function(item) {
  20.                         var isRetina = window.devicePixelRatio > 1.5;
  21.                         var retinaSrc = $(item.el).attr('data-retina');
  22.                         return isRetina && retinaSrc ? retinaSrc : item.el.attr('href');
  23.                     }
  24.                 }
  25.             });
  26.         });
  27.     }
Tags: JavaScript
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement