• Resolved WeFoster

    (@wefoster)


    Thanks for an awesome plugin! I was wondering if it’s possible to open a gallery using a custom button/href? I looked into the PhotoSwipe docs but could not find anything and my level of javascript is not great..

    What I’d like to achieve is inserting a button that opens the first image in the gallery when clicked. Any help would be greatly appreciated!

    Cheers,
    Bowe

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter WeFoster

    (@wefoster)

    As always I got it working just after I posted this.. here’s the code I used..

    <script>
        jQuery( document ).ready(function() {
        	var Trial = jQuery('.gallery-size-thumbnail').find('a:first').attr("href");
        	jQuery("#open-slider").attr("href", Trial);
        	var Text = '<a href="' + Trial +'" data-width="1365" data-height="2048" class="eltd-btn eltd-btn-large eltd-btn-outline eltd-btn-line-left"><span class="eltd-btn-text">View Photos</span></a>';
        	jQuery( ".eltd-page-title.entry-title" ).after( Text );
        });
    </script>

    Hopefully it can be useful for someone else!

    Hi WeFoster,

    I try to use your code but without success.
    And what snippet do I have to insert in my href to launch the gallery?
    (my level of javascript is very low…)
    Is there a specific place to insert this piece of code?

    Cheers,
    John

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Open gallery using a button?’ is closed to new replies.