• Resolved pomponpafraise

    (@pomponpafraise)


    Hello ! I really like your work with this plugin implementation thank you very much ??
    I’m having a question, is there a quick and easy way to make the plugin work after a dynamic dom change ? On the website i’m working on I load the content of the page dynamically with javascript. I’d love to get a way to update the photoswipe data after each page load

    thank you ??

    The page I need help with: [log in to see the link]

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

    (@awelzel)

    The plugin already handles DOM changes in the frontend. So whenever a new image link is added or existing links get removed, the frontend will update the image collection used for PhotoSwipe (see https://github.com/arnowelzel/lightbox-photoswipe/blob/5.2.5/src/js/frontend.js#L473-L494).

    However, all image links added to the page need to contain the neccessary data-lbwps- attributes (at least data-lbwps-width and data-lbwpws-height which is needed to tell PhotoSwipe the size of the final image). I don’t know how you add the images technically – but since you may already use backend code to provide the images, you may add these attributes in the backend side before adding the images in the frontend or add the image links with these attributes set (the size must be the size of the image in the lightbox, PhotoSwipe will use this to build the image frame in the lightbox and to determine if zooming is possible or not).

    To get an idea how this is done in existing posts/pages, see here: https://github.com/arnowelzel/lightbox-photoswipe/blob/5.2.5/src/LightboxPhotoSwipe/LightboxPhotoSwipe.php#L630-L637

    • This reply was modified 7 months, 3 weeks ago by Arno Welzel.
    Thread Starter pomponpafraise

    (@pomponpafraise)

    i’m a bit confused because when I compare the source code of the page generated with and without a dynamic load and it’s the same. there is no “data-lbwps-” attribute anywhere and I don’t know how I should add those. I’m a too bad developper to figure out what’s wrong but thank you for you answer ??

    Thread Starter pomponpafraise

    (@pomponpafraise)

    oh, it’s now working there was no link to the media file in the admin -_-
    but for some reasons it was working on invidual image with a “classic” page load.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Dynamic page load’ is closed to new replies.