J. Hogue
J. Hogue

Reputation: 314

Fancybox one gallery opened via multiple buttons

I am using Fancybox for a work in progress photography site. This is the page that I have working: http://www.marybethmeehan.com/wordpress/portfolio/city-of-champions-project/

It works pretty well, but I have duplication in my gallery. The developer docs are pretty good, but for whatever reason I can't understand how to set this up. I bet it is pretty simple.

The page has three ways to open the one gallery.

When you click the featured image or the number of images, you get the first image in the gallery (which is perfect) BUT the image is actually duplicated. When you go forward form there, you see the same image again as gallery image number 2.

This is because I have use same anchor twice to initiate the gallery. Fancybox is doing what it is supposed to be doing I think. If you search the source for 616.downtown-from-above.jpg you'll see it three times.

So, my simple question is, how do I start the gallery from whatever slide 1 is, without duplicating any contents of the gallery? I need to start the gallery from those two locations, plus allow someone to start anywhere they want via the thumbnail view. I'm sure I am just not understanding something very basic.

Upvotes: 0

Views: 826

Answers (1)

Janis
Janis

Reputation: 8769

You would need to create custom click event for your "count link" and trigger click event for the first (or any other) image link. Something like this (do not forget to remove data-fancybox from count link):

jQuery('.project__gallery-wrapper__count a').on('click', function() {
    jQuery('[data-fancybox="mbm-gallery"]').first().trigger('click');
    return false;
});

btw, you could use fancyBox to display thumbnail list, similarly to this example - https://fancyapps.com/fancybox/3/#ajax

Upvotes: 1

Related Questions