• Resolved lixkamto

    (@lixkamto)


    Try to this work but nothing

    	lightGallery(document.getElementById('photonic-wp-stream-1-container'));
    	$("#button_start").on("click", () => {
    		$("#photonic-wp-stream-1-container > li:first-child > a > img").trigger("click");
    	});

    and the button within same post

    <a id="button_start" href="#">click here</a>

    im using image from wordpress media. anyone have solutions for this?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Sayontan Sinha

    (@sayontan)

    I don’t think this is supposed to work.

    Provide me with a URL and I will look into it.

    Thread Starter lixkamto

    (@lixkamto)

    this my testing url

    Plugin Author Sayontan Sinha

    (@sayontan)

    There are many problems with your JavaScript (you can see an error on your JavaScript console).

    A few things stand out:

    1. You are calling the JavaScript at an arbitrary place, before Photonic’s scripts have been loaded. You will have to work with your theme’s support to figure out how to load the script after Photonic. Photonic’s script loads in the footer by default – you can change this to load in the header instead (via Photonic → Settings → Generic Options → Generic Settings → Include Photonic JS for non-Photonic Images / Videos and Photonic → Settings → Generic Options → Generic Settings → Force JS in header when possible). While this will load Photonic in the header, there is no guarantee that your theme’s script will be called after Photonic’s, which is why you will need to work with your theme’s support.
    2. Your syntax is using $, presumably for jQuery, but you haven’t specified anywhere that $ is refering to jQuery. You have to fix that.
    3. I don’t believe lightGallery is available as a function directly, as you have called in your code. I may be wrong, but once you have fixed the above two problems you will find out. But as such you might not even need that line.
    4. You are using ES6 syntax, which is not going to work for IE 11, but that is a fairly small percentage of users
    5. For the trigger, you don’t need to include img – LightGallery is bound to the a, so if you trigger the click on the a that should be good enough.

    Even after you do all of this, I am not sure if it will work – I have never had to make it work this way, and there might be all types of issues such as double initiation of the gallery if someone clicks on a thumbnail, or issues with deeplinking, or an inability to close the lightbox etc.

    Plugin Author Sayontan Sinha

    (@sayontan)

    I gave this some thought, and here is an alternative suggestion: make use of Photonic’s deep-linking capabilities. Basically, most of Photonic’s lightboxes support deep-linking. You are using LightGallery, and that definitely has deep-linking.

    To do this:

    1. Click on the thumbnail for the photo that you want to open with the button.
    2. When the photo opens up in a lightbox, copy the URL from the browser window.
    3. In your link’s href put the URL that you have copied.
    Thread Starter lixkamto

    (@lixkamto)

    thank you @sayontan for your time. its works if open on new tab/window browser.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to triggering popup galery with button (within same post with gallery)..?’ is closed to new replies.