Skip to content

Instantly share code, notes, and snippets.

@surefirewebserv
Forked from thomasgriffin/gist:9219422
Last active August 29, 2015 14:09
Show Gist options
  • Save surefirewebserv/0eb426cb2ae0337f74bb to your computer and use it in GitHub Desktop.
Save surefirewebserv/0eb426cb2ae0337f74bb to your computer and use it in GitHub Desktop.
Envira Gallery Thumbnail Captions
<?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