Hi

In a special case i needed to have multiple photoswipe galleries on one page. Everything worked except when i clicked on an image in the second gallery, it opens the wrong image.

Example:
I have 2 Galleries. In the first Gallery there are 3 images, in the second 10. When i click on the second image in the first gallery everything is ok. When i click on the 5th image in the second gallery, it opens the 8th image in the second gallery.
The problem is, that the counter counts over all galleries and not only over the gallery, in which the clicked image is in.

I don't now if it is because i use different markup than usual. I use a view which fetches content from a type and displays a (multiple) image field. Then the field formatter is set to photoswipe.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Cogax’s picture

Issue summary: View changes
Cogax’s picture

Assigned: Cogax » Unassigned
Status: Needs work » Needs review
FileSize
539 bytes

I've made a small patch which works for me. It works if there are multiple galleries and also if there is only one.

Cogax’s picture

Issue summary: View changes
Cogax’s picture

Title: Multiple Photoswipe field on one page » Multiple Photoswipe fields on one page
jlockhart’s picture

Having the same problem; I have a view of nodes, each of which has a photoswipe gallery field. Applied the patch and alls well now. Thanks.

ParisLiakos’s picture

I think this approach would break people using .photoswipe CSS class independently. See photoswipe_admin_settings() and photoswipe_always_load_non_admin variable's description.

legolasbo’s picture

FileSize
853 bytes

I think @ParisLiakos is correct and have adjusted the patch accordingly. It now checks if the clicked element is part of a gallery. If that is the case, it will look for the index within that gallery, otherwise it will look for the global index of the clicked element.

legolasbo’s picture

Version: 7.x-2.0-beta2 » 8.x-1.x-dev
Issue tags: +Needs backport to D7

I've checked and found out that this bug is also applicable to 8.x-1.x. I have therefore changed the version to which this issue applies and tagged it as needs backport. The patch applies cleanly to both the 7.x and the 8.x branch, so it can be committed to both after RTBC.

gifad’s picture

#7 works fine, but it keeps theindex variable defined (implicitly) as global; this is present in the current implementation, but is certainly not intended.
The attached patch fixes that (and make the code a bit more concise..)
(applies to 7.x as well)

dcsambrook’s picture

#9 Worked for me. Thank you.

davidam’s picture

#9 it's running to me, too!

vinmassaro’s picture

The patch in #9 is working great in D7. Thanks!

igorski’s picture

Version: 8.x-1.x-dev » 7.x-2.x-dev
Status: Needs review » Reviewed & tested by the community

Since #9 fixes the Javascript, it works for D7 and D8. Please commit to D7 first or to both D7 and D8. Thanks!

idflorin’s picture

#9 Worked for me. Test url http://bit.ly/2upbQMq

sun’s picture

#2894797: Wrong image is opened with multiple galleries just fixed this for D8. Can you verify whether the same fix works in D7?

Anybody’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

We need feedback if this is already fixed. See #15. I'll postpone it now.

arpas’s picture

Version: 7.x-2.x-dev » 7.x-2.0-beta4

The patch #9 worked for D7. Please contribute to D7.

arpas’s picture

Status: Postponed (maintainer needs more info) » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 9: photoswipe-multiple-2508091-9.patch, failed testing. View results

Anybody’s picture

Version: 7.x-2.0-beta4 » 7.x-2.x-dev

  • Anybody committed 7ad16d6 on 7.x-2.x
    Issue #2508091 by Cogax, legolasbo, gifad, Anybody, arpas: Multiple...
Anybody’s picture

Status: Needs work » Fixed

#9 was committed to latest dev now. Please test it and provide feedback to have a new stable release afterwards.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.