Skip to content

Instantly share code, notes, and snippets.

@amdrew
Last active December 21, 2015 22:18
Show Gist options
  • Save amdrew/6373901 to your computer and use it in GitHub Desktop.
Save amdrew/6373901 to your computer and use it in GitHub Desktop.
Make a lightbox script use both the image caption and description as the title for when the image is enlarged.
<?php
/**
* Filter Easy Image Gallery HTML to add description
*
*/
function my_child_theme_easy_image_gallery_description( $html, $rel, $image_link, $image_class, $image_caption, $image, $attachment_id, $post_id ) {
// get the image's description
$image_description = get_post( $attachment_id )->post_content ? get_post( $attachment_id )->post_content : '';
// add the description to the title attribute
if ( function_exists( 'easy_image_gallery_has_linked_images' ) && easy_image_gallery_has_linked_images() )
$html = sprintf( '<li><a %s href="%s" class="%s" title="%s - %s"><i class="icon-view"></i><span class="overlay"></span>%s</a></li>', $rel, $image_link, $image_class, $image_caption, $image_description, $image );
else
$html = sprintf( '<li>%s</li>', $image );
return $html;
}
add_filter( 'easy_image_gallery_html', 'my_child_theme_easy_image_gallery_description', 10, 8 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment