Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #647950

    Hi,

    Is there a way of making a lightbox appear when a button is clicked?

    #648429

    Hey markpevans,

    Yes that should be possible, could you provide us with a link to the site in question so that we can take a closer look please?

    Regards,
    Rikard

    #648484

    Hi Rikard,

    I am currently building the new site design on a temp sub domain http://temp.mamas-box.com/

    Here is a screenshot of the button that I would like to add a popup lightbox to when clicked:

    https://www.dropbox.com/s/dchgf4mb52bhbu1/Screen%20Shot%202016-06-15%20at%2011.14.12%20am.png?dl=0

    #648653

    Hey!

    What exactly would you like to display when button is clicked? If it is a content, please see – http://dimsemenov.com/plugins/magnific-popup/documentation.html#inline-type

    Regards,
    Yigit

    #648695

    Hi Yigit,

    I would like a gallery of images to pop up when clicked.

    #650061

    Hi,

    Remove the button then replace it with a code block. Add this code:

    
    <div class="gallery-wrap">
    <div class="avia-button-wrap avia-button-left"><a href="IMAGE URL HERE" class="galleryItem avia-button  avia-icon_select-no avia-color-aqua avia-size-medium avia-position-left" data-group="3"><span class="avia_iconbox_title" >SEE SAMPLE BOXES</span></a></div>
    <a class="galleryItem galleryItemSet" href="IMAGE URL HERE" data-group="3"></a>
                        <a class="galleryItem galleryItemSet" href="IMAGE URL HERE" data-group="3"></a>
                        <a class="galleryItem galleryItemSet" href="IMAGE URL HERE" data-group="3"></a></div>
    

    Add the image url in place of the placeholders (IMAGE URL HERE). After that, add this in the functions.php file:

    // custom lightbox
    function add_custom_script_lightbox(){
    ?>
    <script>
    (function($){
    	$(document).ready(function() {
    		var groups = {};
    		$('.galleryItem').each(function() {
    		  var id = parseInt($(this).attr('data-group'), 10);
    
    		  if(!groups[id]) {
    		    groups[id] = [];
    		  }
    
    		  groups[id].push( this );
    		});
    
    		$.each(groups, function() {
    
    		  $(this).magnificPopup({
    		      type: 'image',
    		      closeOnContentClick: true,
    		      closeBtnInside: false,
    		      gallery: { enabled:true }
    		  })
    
    		});
    	});
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'add_custom_script_lightbox');
    

    And this css code in the Quick CSS field:

    .mfp-ready .mfp-figure {
        opacity: 1;
    }
    
    .galleryItemSet {
        display: none;
    }

    Best regards,
    Ismael

    #650138

    Thank you Ismael. I will try this and see if it works :)

    #650207

    Hey!

    Please keep us updated for the solution if works or not, maybe someone else also can use it!

    Thanks a lot for!

    Cheers!
    Basilis

    #652108

    Hi Guys,

    This code worked perfectly.

    Thank you for your support as always.

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘lightbox on button click’ is closed to new replies.