-
AuthorPosts
-
August 18, 2014 at 5:04 pm #305853
Is it possible to have all images and galleries show the same lightbox? Currently, if I have 5 images and two galleries on a page, there will be three lightboxes. One lightbox will show all of the individual images. Each gallery also gets its own lightbox. Is it possible to have just one lightbox, so clicking any image or gallery shows all of the images in the lightbox?
August 19, 2014 at 5:11 pm #306432Hey davisar!
Yes, open up wp-content/themes/enfold/config-templatebuilder/avia-shortcodes/gallery.php and replace:
$thumbs .= " <a href='".$link[0]."' data-rel='gallery-".self::$gallery."' data-prev-img='".$prev[0]."' {$class} data-onclick='{$counter}' title='".$description."' $markup_url><img {$tooltip} src='".$img[0]."' width='".$img[1]."' height='".$img[2]."' title='".$title."' alt='".$alt."' /></a>";
with
$thumbs .= " <a href='".$link[0]."' data-rel='gallery' data-prev-img='".$prev[0]."' {$class} data-onclick='{$counter}' title='".$description."' $markup_url><img {$tooltip} src='".$img[0]."' width='".$img[1]."' height='".$img[2]."' title='".$title."' alt='".$alt."' /></a>";
This should link all galleries to the same lightbox.
Cheers!
PeterAugust 19, 2014 at 6:33 pm #306459Unfortunately, that didn’t work. I replaced the code, but nothing happened.
Also, is there a way to do this with the child theme?
August 20, 2014 at 5:08 am #306600Hey!
Thank you for the update.
Insert a color section then place all galleries inside this section. Apply an id to it using the For Developers: Section ID field. Let’s use “gallery-section” for example. Add this on functions.php:
function gallery_lightbox() { ?> <script type="text/javascript"> jQuery(window).load(function(){ jQuery('#gallery-section').each(function() { // the containers for all your galleries jQuery(this).magnificPopup({ delegate: 'a', // the selector for gallery item type: 'image', gallery: { enabled:true } }); }); }); </script> <?php } add_action('wp_head', 'gallery_lightbox');
There’s a catch to this, you need to have at least two images on a single gallery.
Regards,
IsmaelAugust 20, 2014 at 2:00 pm #306835The images are in posts that don’t support color sections.
August 21, 2014 at 7:42 am #307200Hey!
Use this code instead:
function gallery_lightbox() { ?> <script type="text/javascript"> jQuery(window).load(function(){ jQuery('.avia-gallery').each(function() { // the containers for all your galleries jQuery(this).magnificPopup({ delegate: 'a', // the selector for gallery item type: 'image', gallery: { enabled:true } }); }); }); </script> <?php } if(is_singular('post')) add_action('wp_head', 'gallery_lightbox');
Cheers!
JosueAugust 21, 2014 at 2:16 pm #307357That didn’t work either.
August 21, 2014 at 6:13 pm #307485 -
AuthorPosts
- The topic ‘lightbox’ is closed to new replies.