-
-
Save ivan-s-1/8c272b6746ca7d172e83b5db45c2b271 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).closest('.wp-block-gallery').find('a'); | |
| var gallery = []; | |
| galleryImages.each(function( index, galleryItem ) { | |
| var caption = $(this).parent().find('figcaption') ? $(this).find('img').attr('alt') : $(this).parent().find('figcaption') ; | |
| gallery.push({ | |
| src : galleryItem.href, | |
| opts : { | |
| caption: caption | |
| } | |
| }) | |
| }); | |
| $.fancybox.open( gallery, { loop: false , index: $(this).closest('li').index() } ); | |
| return false; | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment