Skip to content

Instantly share code, notes, and snippets.

@ejntaylor
Created June 17, 2015 07:52
Show Gist options
  • Save ejntaylor/0bb59dca0afc8a2b83d6 to your computer and use it in GitHub Desktop.
Save ejntaylor/0bb59dca0afc8a2b83d6 to your computer and use it in GitHub Desktop.
OBox Layers - Adds comment to featured image function
/**
* Post Featured Media
*
* @param int $attachmentid ID for attachment
* @param int $size Media size to use
* @param int $video oEmbed code
*
* @return string $media_output Feature Image or Video
*/
if( !function_exists( 'layers_post_featured_media' ) ) {
function layers_post_featured_media( $args = array() ){
global $post;
$defaults = array (
'postid' => $post->ID,
'wrap' => 'div',
'wrap_class' => 'thumbnail',
'size' => 'medium',
'comment' => false
);
$args = wp_parse_args( $args, $defaults );
extract( $args, EXTR_SKIP );
$post_meta = get_post_meta( $postid, 'layers', true );
$featured_media = layers_get_feature_media( get_post_thumbnail_id( $postid ), $size, ( isset( $post_meta[ 'video-url' ] ) ? $post_meta[ 'video-url' ] : NULL ), $postid );
if( NULL == $featured_media ) return;
$output = '';
if( NULL != $featured_media ){
$output .= $featured_media;
}
if( !isset( $hide_href ) && !isset( $post_meta[ 'video-url' ] ) && ( !is_single() && !is_page_template( 'template-blog.php' ) ) ){
$output = '<a href="' .get_permalink( $postid ) . '">' . $output . '</a>';
}
if ($comment){
$output .= '<span class="caption">' . get_post( get_post_thumbnail_id() )->post_excerpt . '</span>';
}
if( '' != $wrap ) {
$output = '<'.$wrap. ( '' != $wrap_class ? ' class="' . $wrap_class . '"' : '' ) . '>' . $output . '</' . $wrap . '>';
}
return $output;
}
} // layers_post_featured_media
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment