I've used the getting started code from the PhotoSwipe documentation to build my simple photo gallery. Some of the larger gallery thumbnails are spread over more than one page. I ended up dividing the large galleries into smaller pages because my web server was falling over when too many thumbnails on one page were being loaded by the browser.
My problem is that when viewing the larger gallery full-size photos, PhotoSwipe will only show the photos from that page, and not the whole gallery. I thought I'd solved the problem by putting the images from the other pages in a separate with display: set to none and no tag, just an to the photo. This works, I can go to any thumbnail page and swipe through the entire album.
What doesn't work is that if I have swiped to a photo that isn't in the current thumbail page, trying to close PhotoSwipe causes it to crash and I have to refresh the page. I think this is because when you close photoswipe it is looking for the thumbnail of the photo you're currently looking at, and it's not there. The problem goes away if I add the correct tag to the thumbnails in the non displayed block, but this defeats the purpose of paginating the gallery in the first place as some browsers download all the images even if they're not displayed.
Is there a simple way around this?