Skip to content

Commit 8917453

Browse files
authored
Merge pull request #16 from skirridsystems/feature/animation
Add filter to allow BaguetteBox animation to be set
2 parents edbbb11 + d2730bc commit 8917453

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

gallery-block-lightbox.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,19 @@ function register_assets() {
4949
*/
5050
$baguettebox_captions = apply_filters( 'baguettebox_captions', 'function(t){var e=t.parentElement.classList.contains("wp-block-image")||t.parentElement.classList.contains("wp-block-media-text__media")?t.parentElement.querySelector("figcaption"):t.parentElement.parentElement.querySelector("figcaption,dd");return!!e&&e.innerHTML}' );
5151

52-
wp_add_inline_script( 'baguettebox', 'window.addEventListener("load", function() {baguetteBox.run("' . $baguettebox_selector . '",{captions:' . $baguettebox_captions . ',filter:' . $baguettebox_filter . ',ignoreClass:"' . $baguettebox_ignoreclass . '"});});' );
52+
/**
53+
* Filters the animation attribute of baguetteBox.js
54+
*
55+
* @since 1.16
56+
*
57+
* @param string $value Use the given animation style on image transitions.
58+
* 'slideIn' | 'fadeIn' | 'false'
59+
*/
60+
$baguettebox_animation = apply_filters( 'baguettebox_animation', 'slideIn' );
61+
62+
$baguettebox_options = "{captions:{$baguettebox_captions},filter:{$baguettebox_filter},ignoreClass:'{$baguettebox_ignoreclass}',animation:'{$baguettebox_animation}'}";
5363

64+
wp_add_inline_script( "baguettebox", "window.addEventListener('load', function() {baguetteBox.run('{$baguettebox_selector}',{$baguettebox_options});});" );
5465
}
5566
add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\register_assets' );
5667

0 commit comments

Comments
 (0)