-
AuthorPosts
-
June 14, 2016 at 1:09 pm #647950
Hi,
Is there a way of making a lightbox appear when a button is clicked?
June 15, 2016 at 7:03 am #648429Hey 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,
RikardJune 15, 2016 at 9:15 am #648484Hi 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
June 15, 2016 at 3:31 pm #648653Hey!
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,
YigitJune 15, 2016 at 4:16 pm #648695Hi Yigit,
I would like a gallery of images to pop up when clicked.
June 18, 2016 at 3:35 am #650061Hi,
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,
IsmaelJune 18, 2016 at 11:59 am #650138Thank you Ismael. I will try this and see if it works :)
June 18, 2016 at 5:49 pm #650207Hey!
Please keep us updated for the solution if works or not, maybe someone else also can use it!
Thanks a lot for!
Cheers!
BasilisJune 22, 2016 at 2:42 pm #652108Hi Guys,
This code worked perfectly.
Thank you for your support as always.
-
AuthorPosts
- The topic ‘lightbox on button click’ is closed to new replies.