-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
19 additions
and
2 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* Description: Adds a Lightbox to the Block Editor (Gutenberg) Gallery & Image Block. | ||
* Author: Johannes Kinast <[email protected]> | ||
* Author URI: https://go-around.de | ||
* Version: 1.14 | ||
* Version: 1.15 | ||
*/ | ||
namespace Gallery_Block_Lightbox; | ||
|
||
|
@@ -40,7 +40,16 @@ function register_assets() { | |
*/ | ||
$baguettebox_ignoreclass = apply_filters( 'baguettebox_ignoreclass', 'no-lightbox' ); | ||
|
||
wp_add_inline_script( 'baguettebox', 'window.addEventListener("load", function() {baguetteBox.run("' . $baguettebox_selector . '",{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},filter:' . $baguettebox_filter . ',ignoreClass:"' . $baguettebox_ignoreclass . '"});});' ); | ||
/** | ||
* Filters the captions attribute of baguetteBox.js | ||
* | ||
* @since 1.15 | ||
* | ||
* @param string $value A JavaScript function that receives the image <a> element and returns the caption for a given image | ||
*/ | ||
$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}' ); | ||
|
||
wp_add_inline_script( 'baguettebox', 'window.addEventListener("load", function() {baguetteBox.run("' . $baguettebox_selector . '",{captions:' . $baguettebox_captions . ',filter:' . $baguettebox_filter . ',ignoreClass:"' . $baguettebox_ignoreclass . '"});});' ); | ||
|
||
} | ||
add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\register_assets' ); | ||
|