Skip to content

Instantly share code, notes, and snippets.

@kyledurand
Last active August 29, 2015 14:11
Show Gist options
  • Save kyledurand/6c609ae1345963487a3c to your computer and use it in GitHub Desktop.
Save kyledurand/6c609ae1345963487a3c to your computer and use it in GitHub Desktop.
[Launchpad] Turn product page images into fancybox gallery

Turning a product page into a fancybox gallery

  1. Find the fancybox code in scripts.js. If your theme doesn't have fancy box loaded then load it up and add the sprites.

  2. Find the code, it should look something like this:

$("a.zoom").fancybox({ padding:0, 'titleShow': false, overlayColor: '#000000', overlayOpacity: 0.2, });

  1. Add rel attribute (Check the selectors)

$("a.zoom").fancybox({ padding:0, 'titleShow': false, overlayColor: '#000000', overlayOpacity: 0.2, }).attr('rel','gallery');

  1. Add rel to the thumbs. We disregard the first thumbnail image as its always a copy of the featured image and we don't want it to show up twice in the gallery; hense the :not(:first) selector.

$(".image.span2 a:not(:first)").fancybox({ padding:0, 'titleShow': false, overlayColor: '#000000', overlayOpacity: 0.2, }).attr('rel','gallery

  1. Disable switch image while popup is enabled (use an if statement and check against theme settings) i.e. {% if settings.enable_product_image_zoom %} switchImage($(this).attr('href'), null, $('.featured img')[0]); {% endif %}
  2. Test thoroughly.
$("a.zoom").fancybox({
padding:0,
'titleShow': false,
overlayColor: '#000000',
overlayOpacity: 0.2,
}).attr('rel','gallery');
$(".image.span2 a:not(:first)").fancybox({
padding:0,
'titleShow': false,
overlayColor: '#000000',
overlayOpacity: 0.2,
}).attr('rel','gallery');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment