The simpler media website CMS
Hello. I am coming along nicely with my site, with great thanks to those here who have been helping me.
On my image.php page, since images can come from a number of sources (the album/sub-album itself, a tag link, a direct search, etc.), I wanted to put a link to the original album an image is pulled from, so the viewer can browse that album. To do this, I have used the following on my image.php page:
From the album: <?php printAlbumURL(getAlbumTitle(), getAlbumTitle(), null, null); ?>
This works, unless the search result brings up more than one page. For example, If I search for "Mary" I will get over 400 results. Whether I use infinite scroll or not, once I get to an image past the first page, the "from album" link attaches the page number of the search results.
This means that if on the 5th page of "Mary" results, I pull a picture from a small album with only 20 pictures, the link the above code gives me will be for "that-album/page/5/" even though that album does not have a page five. This results in a 404 error when someone clicks on the link. Interestingly, if I click the "back" button after hitting that 404, I go back to that same image page and then refresh the image page, it does not append the "/page/5/" and the link then works correctly.
It seems to be getting "/page/5/" not from the album it pulls the image from, but from the initial search position, and only when directly called from the search position. The link itself, if refreshed after moving away from it, or if the link to that image page is copied and pasted into a new browser, the "From the album" link works as expected. Also, when refreshed in a new tab (or after moving back from the 404 page the breadcrumb reflects the original album the image is from and not the search link.
Google brought me to this page on github: https://github.com/zenphoto/zenphoto/issues/669 and I played around with my print_album_menu.php a bit, but clearly that php page has changed a lot since 2014, and I could not fix the issue.
Additionally, this feature does cause an issue with images pulled from second pages of albums when using infinite scroll, as the /page/x/ link, while correct if the image was derived from the album itself (rather than via a tag link or search), only loads the second (or x) half/portion of the infinite scroll page, making it impossible to see the full album from which the image comes. So whether the page is legit (as when an image is called directly from its album) or not legit (as when the page number is from the page in search results and not actually from the page of the album where the image originates), having it attached to the URL gives undesirable behavior.
Thoughts on how to have my link above not add the page number- especially the fictitious page number it seems to be gathering from the image's position in search results?
I would greatly appreciate any ideas.