• Resolved arekj

    (@arekj)


    Hi.

    I have a problem with Lightbox with PhotoSwipe and infinite loop. Regardless of whether I have the “Allow infinite loop” option checked or unchecked. As you scroll down, the lightbox grows larger by more photos.
    For example:
    1. In post 1 I have 3 photos. 3 is displayed in the lightbox
    2. I’m going down
    3. In post 2 I have 4 photos. 7 is displayed in the lightbox
    4. I’m going down
    5. In post 3 I have 5 photos. 12 photos are displayed in the lightbox
    E.t.c.

    Do you know how to solve this problem?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Arno Welzel

    (@awelzel)

    “Allow infinite loop” has nothing to do how many images are displayed. It meens that after the last image you get back to the first image when swiping. Otherwise the lightbox will stop at the last image (or first when swiping backwards).

    Without seeing the actual site where this happens I don’t know how to solve your issue.

    Do you have some kind of dynamic content loader in place which adds images while users scroll down? If yes, try turning this off to see wether this changes anything. Browsers support “lazy loading” of images nowadays and WordPress adds this attribute by default for images anyway, so there is no need to have JavaScript based solutions for this.

    Thread Starter arekj

    (@arekj)

    Hi,
    Thank you for your answer.

    I don’t have lazyload enabled in javascript.

    As I scroll down my page, more posts are loading (Infinite Scroll/Infinite Load). When a new post is loaded, new photos are added to the lightbox – the plugin does not take into account that these are two separate posts.

    I don’t have this page online right now so can’t link. Probably in 2 weeks I will put it on the Internet and you will be able to see what it is about.

    Thread Starter arekj

    (@arekj)

    Hi,

    You can see the problem here:
    https://furcy.pl/nowy-opel-astra-sports-tourer-premiera/

    Do you have any ideas on how to solve it?

    Regards,
    Arek

    Plugin Author Arno Welzel

    (@awelzel)

    There is no problem – the content is just not there before the user scrolls down.

    When I first load the page and scroll down a bit to get to the first gallery, about 23 images are on the page.

    Then when I scroll down – and only then(!) – more content is loaded, so the gallery now contains 36 images. And these 13 images were not(!) there before. You can also see how the scroll bar of the browser changes in this situation – it becomes smaller because more content is loaded from the server when scrolling down.

    To see how content is usually handled by WordPress, see this example: https://arnowelzel.de/en/england-2017 – the whole article is completely loaded and not only when scrolling down.

    The only solution for your problem would be to disable lazy loading – either turn off the plugin which does this or modify the theme if possible, If the content is not there, the plugin can not show it. There is no “fix” for this. Lightbox with PhotoSwipe can not show images which do not exist before scrolling down.

    • This reply was modified 2 years, 11 months ago by Arno Welzel.
    Thread Starter arekj

    (@arekj)

    I don’t think we understood each other.

    The point is that the lightbox creates one huge gallery from all the entries loaded by ifninite loop.

    I would like galleries to be separate for subsequent entries.

    For example if you open this link: https://furcy.pl/nowy-opel-astra-sports-tourer-premiera/

    And it goes to the gallery then there are 8 photos in the lightbox.
    And that’s okay.

    Then we go down and another entry is loaded. Now, after going to the gallery, we are shown 23 photos there. It’s bad.
    Should show 23-8 = 15 photos. Because there are only 15 photos in the gallery in the second post.

    Etc.

    I just wish each post had a separate lightbox gallery.

    Thread Starter arekj

    (@arekj)

    In short: it is not the lazy load of images that causes the problem here, but the dynamic loading of next entries.
    Is it possible to make entries separate galleries?

    Plugin Author Arno Welzel

    (@awelzel)

    Again – how many images are used has nothing to do with the “Alow infinite loop” option.

    Just turn the option off and you will see that nothing will change. The number of image used will still be the same. The option only controls if the image swiping will stop at the last image in Photoswipe or not.

    Having all images from one post in its own lightbox is not possible. You must use either WordPress gallery blocks or Gutenberg gallery blocks and enable the option “Show WordPress galleries and Gutenberg gallery blocks in separate lightboxes”.

    Edit:

    The images from different posts have no indication from which post they are. Therefore the frontend script which collects the images for PhotoSwipe cannot know if one image is from post 1 and another image is from post 2.

    If the “Show WordPress galleries and Gutenberg gallery blocks in separate lightboxes” is enabled, the backend will add a hook to the gallery output to create a unique gallery ID which will then be used by the frontend.

    However to do this for post overviews as well, the plugin would need to hook to content loop and modify every post before the content loop outputs it.

    BUT: the post content is already filtered at an earlier stage when rendering the post because when viewing a single post the Lightbox needs to work as well and not only on pages which have a content loop. This would mean, that every single post would have to processed TWICE – once after the post was rendered and a second time during the content loop of the theme. This would create a lot of additional load to the server for a very specific use case which is usally never relevant – if you display 30 images on the homepage because a user usually expects to be able to swipe through all images and not only the 4 or 10 of one post.

    • This reply was modified 2 years, 11 months ago by Arno Welzel.
    • This reply was modified 2 years, 11 months ago by Arno Welzel.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Problem with infinite loop’ is closed to new replies.