Skip to content

Instantly share code, notes, and snippets.

@whistlerbrad
Created September 10, 2019 05:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whistlerbrad/3cab138e2d6a7928cf19a713e19550cb to your computer and use it in GitHub Desktop.
Save whistlerbrad/3cab138e2d6a7928cf19a713e19550cb to your computer and use it in GitHub Desktop.
/* -- code for image gallery pop-up -- */
// add to the very bottom of theme's javascript file
$(document).ready(function() {
$('#shopify-section-press img').each(function() {
var currentImage = $(this);
currentImage.wrap("<a class='image-link' title='" + currentImage.attr("title") + "' href='" + currentImage.attr("src") + "'</a>");
});
$('.image-link').magnificPopup({
type: 'image',
titleSrc: function(item) {
return item.el.attr('title');
},
gallery: {
enabled: true,
preload: [0,2],
navigateByImgClick: true,
arrowMarkup: '<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',
tPrev: 'Previous (Left arrow key)',
tNext: 'Next (Right arrow key)',
tCounter: '<span class="mfp-counter">%curr% of %total%</span>'
},
mainClass: 'mfp-with-zoom',
zoom: {
enabled: true,
duration: 300,
easing: 'ease-in-out',
opener: function(openerElement) {
return openerElement.is('img') ? openerElement : openerElement.find('img');
}
}
});
});
/* - end - */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment