Created
November 26, 2018 02:57
-
-
Save usainicola/b8291020d78f4432f2786ac47b42056c to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
add_filter('post_gallery','bp_custom_gallery_html',10,2); | |
function bp_custom_gallery_html($string,$attr){ | |
$uniqid = uniqid(); | |
$output = '<div class="bp_gallery_'.$uniqid.'">'; | |
$attachments = get_posts(array('include' => $attr['ids'],'post_type' => 'attachment')); | |
foreach($attachments as $key => $value){ | |
$output .= '<img src="'.wp_get_attachment_image_src($value->ID, 'large')[0].'" alt="Bottega Progetti Gallery Image"/>'; | |
} | |
$output .= "</div>"; | |
$output .= "<script>"; | |
$output .= "window.addEventListener('load',function() {"; | |
$output .= "tns({"; | |
$output .= "container: '.bp_gallery_".$uniqid."',"; | |
$output .= "items: 1,"; | |
$output .= "autoplay: true,"; | |
$output .= "autoplayHoverPause: false,"; | |
$output .= "controls: false,"; | |
$output .= "nav: true,"; | |
$output .= "autoplayButtonOutput: false,"; | |
$output .= "mouseDrag: true,"; | |
$output .= "});"; | |
$output .= "});"; | |
$output .= "</script>"; | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment