-
-
Save darinronne/6a8ac409324f63a0f71d6939b39ca013 to your computer and use it in GitHub Desktop.
fancybox 3 integration into wordpress Gutenberg gallery block
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ($('.wp-block-gallery')) { | |
$('.blocks-gallery-item').click(function() { | |
var galleryImages = $(this).parent().find('a'); | |
var gallery = []; | |
galleryImages.each(function( index, galleryItem ) { | |
var caption = $(this).parent().find('figcaption').html(); | |
gallery.push({ | |
src : galleryItem.href, | |
opts : { | |
caption: caption | |
} | |
}) | |
}); | |
$.fancybox.open( gallery, { loop: false }, $(this).index() ); | |
return false; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment