Created
November 28, 2014 12:23
-
-
Save pasadamedia/9ec5c42f696dcf969e7c to your computer and use it in GitHub Desktop.
Event featured image wrapped in a link to a larger version of the same image.
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
/** | |
* Event featured image wrapped in a link to a larger version of the same image. | |
* | |
* Replaces tribe_event_featured_image to enable link to a larger version for display in a lightbox. | |
* Called in custom single event template file (/pasada/tribe-events/single-event.php). | |
* | |
*/ | |
function pasada_tribe_event_featured_image( $post_id = null, $size = 'full', $size2 = 'large', $link = true ) { | |
if ( is_null( $post_id ) ) { | |
$post_id = get_the_ID(); | |
} | |
$image_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), $size ); | |
$image_src2 = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), $size2 ); | |
$featured_image = ''; | |
//if link is not specifically excluded, then include <a> | |
if ( ! empty( $image_src ) && $link ) { | |
$featured_image .= '<div class="tribe-events-event-image"><a href="' . $image_src2[0] . '" title="' . get_the_title( $post_id ) . '" rel="lightbox"><img src="' . $image_src[0] . '" title="' . get_the_title( $post_id ) . '" /></a></div>'; | |
} elseif ( ! empty( $image_src ) ) { | |
$featured_image .= '<div class="tribe-events-event-image"><img src="' . $image_src[0] . '" title="' . get_the_title( $post_id ) . '" /></div>'; | |
} | |
return apply_filters( 'pasada_tribe_event_featured_image', $featured_image, $post_id, $size, $image_src ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment