-
-
Save surefirewebserv/0eb426cb2ae0337f74bb to your computer and use it in GitHub Desktop.
Envira Gallery Thumbnail Captions
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
<?php | |
add_filter( 'envira_gallery_output_after_link', 'tgm_envira_gallery_caption', 10, 5 ); | |
/** | |
* Adds a caption below each image in the gallery. | |
* | |
* @since 1.0.0 | |
* | |
* @param string $output String of gallery output. | |
* @param mixed $id The ID of the gallery. | |
* @param array $item Array of data about the image. | |
* @param array $data Array of gallery data. | |
* @param int $i The current index in the gallery. | |
* @return string $output Amended string of gallery output. | |
*/ | |
function tgm_envira_gallery_caption( $output, $id, $item, $data, $i ) { | |
if ( ! empty( $item['title'] ) ) { | |
$caption = '<div class="envira-gallery-captioned-data">'; | |
$caption .= '<p class="envira-gallery-captioned-text">'; | |
$caption .= $item['title']; | |
$caption .= '</p>'; | |
$caption .= '</div>'; | |
$caption = apply_filters( 'envira_gallery_themes_captioned_output', $caption, $id, $item, $data, $i ); | |
return $output . $caption; | |
} | |
// Return the output. | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment