DanielMuller / koken-plugin-photoswipe

Photoswipe integration for Koken
36 stars 13 forks source link

In version 2 themes, copying and pasting a URL to a photo within photoswipe brings up the album instead. #22

Closed laklare closed 8 years ago

laklare commented 8 years ago

Is there any way to get a direct link to a photo when using a theme such as Madison 2, Axis 2, or Regale 2? When I bring up a photo in the photoswipe lightbox and copy the URL, that URL takes me to the album without photoswipe open.

This behavior is different than when using version 1 themes. In version 1 themes, a copied URL will take the visitor directly to the photo opened in the photoswipe lightbox. For some reason, the lightbox is not being triggered in 2.0 themes based on the URL variables.

I've confirmed that this has been the case in all versions of koken-plugin-photoswipe going back six months, including the current version. It would be very helpful to have some means of generating a link that actually takes a visitor directly to a specific photo. Is there any chance that could be done? Thank you.

DanielMuller commented 8 years ago

Does it fail with all images of an album or only on the ones loaded after scroll?

laklare commented 8 years ago

It fails with all images, even the first one within an album. For instance, a URL ending in #&gid=1&pid=000-211-n07c9263 opens the album view for a Pillar-based theme.

I see the part of the code where the lightbox ought to be triggered to open based on URL variables, but for some reason it's not happening with these themes.

// Parse URL and open gallery if it contains #&pid=3&gid=1
var hashData = photoswipeParseHash();
if(hashData.pid && hashData.gid) {
    openPhotoSwipe( hashData.pid, true, true );
}
laklare commented 8 years ago

Thanks! This seems to have mostly fixed the problems in all three Pillar-based themes, which is great. I did find two new issues, however:

1) I'm getting some new odd behavior in Regale 2, but not Madison 2 or Axis 2. When I paste a link to a photo, I get the photoswipe lightbox with the correct image displayed just fine. However, when I click the close button and return to grid view, photoswipe won't open again and the standard koken lightbox comes up when I click on an image. This behavior fixes itself if I scroll down far enough to trigger the lazy-loading of additional images. After that, photoswipe works again. This only happens for me in Regale 2...for some reason photoswipe isn't being initialized at first when there is a pid and gid in the URL.

2) This is minor, but the number of total photos that Photoswipe reports always seems to be double when the URL links directly to a photo (contains a pid and gid). For instance, if I copy the URL for the first image in an album containing 30 photos (1/30), the Photoswipe lightbox will says 1/60. At least in Pillar-based themes.

DanielMuller commented 8 years ago

Let me look into that. I created 2 new issues: #25, #26 for easier tracking

laklare commented 8 years ago

Regarding your question "Does it fail with all images of an album or only on the ones loaded after scroll?" I wanted to mention that direct links to photos in the photoswipe lightbox now do work for Pillar-based themes, but only for the photos shown on the first page before the lazy-loading is triggered. Links copied from the photoswipe lightbox to any photos after that point won't work, presumably because photoswipe can't see them.

Do you think there is any way to fix that? I've tried to figure out a way to get Pillar to load everything without scrolling, but I haven't found a solution. As is, people (including myself) can't easily share links to my photos and I have to tell everyone in advance that the lightbox doesn't show all the photos in a given album unless they scroll down first. It makes the portfolio seem very amateur and it isn't that useful. I'm leaning toward going back to the built in lightbox, as slow and terrible as it is. I may even give up on Koken entirely at this point and switch to something else. I put so much work into customizing my paid Koken theme installations, but they are just missing this component.

Thanks for all your work on this, regardless. It got me through the past year or so with Koken, especially when I was on shared hosting, prior to switching to VPS hosting (much faster, but still too slow for built in Koken lightbox)

DanielMuller commented 8 years ago

I don't think there is an easy way with this plugin. I made it with Axis1 in mind, which was just a good old plain HTML page per album. And it parses only what exists. I tried to understand Pillar, but I gave up. Ideally data should be taken from Koken's API and not from the resulting HTML. I am just lacking free time to invest into a full rewrite.

laklare commented 8 years ago

I was able to make Photoswipe work for me with the new themes by raising the limit of how many images are loaded from 30 to 100 for Regale 2 and 80 to 100 for Madison 2 and Axis 2. These are set inside the various configuration files for the three Pillar-based themes. Although this does add more load on my server, it lets me put a maximum of 100 photos per album, which is a reasonable amount. I can then share direct links to those images and the photoswipe lightbox will come up for those (only up to image 100). This also allows 100 images to appear in photoswipe without having to scroll down in the page first. i think this will work for me.

For Regale 2 and Madison 2, the limits are hard-coded. I set up a daily cron job to modify the lens files in the theme so my changes will be reapplied after future updates. The commands I used to raise the limit to 100 (the maximum allowed for Koken API requests) are as follows:

sed -i 's/30/100/g' /<koken_installation>/storage/themes/<theme_directory>/contents.lens sed -i 's/30/100/g' /<koken_installation>/storage/themes/<theme_directory>/album.lens

For Axis 2, the limit for each template can be set in the site editor of the koken admin panel. However, the theme comes packaged with a limit of 80, but this can be increased to 100 by editing the info.json file as follows. The value can then be raised to 100 in the admin panel.

sed -i 's/\s80,/100,/g' /<koken_installation>/storage/themes/<theme_directory>/info.json