mirror of
git://develop.git.wordpress.org/
synced 2025-02-27 01:52:24 +01:00
Link post format images if a URL is provided. Make the URL available via get_the_post_format_url().
props wonderboymusic, obenland. fixes #23964. git-svn-id: https://develop.svn.wordpress.org/trunk@23992 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
247167445e
commit
95c3de8a9f
@ -2400,8 +2400,13 @@ function get_the_post_format_image( $attached_size = 'full', &$post = null ) {
|
||||
return $post->format_content;
|
||||
|
||||
$meta = get_post_format_meta( $post->ID );
|
||||
|
||||
$link_fmt = '%s';
|
||||
if ( ! empty( $meta['url'] ) )
|
||||
$link_fmt = '<a href="' . esc_url( $meta['url'] ) . '">%s</a>';
|
||||
|
||||
if ( ! empty( $meta['image'] ) ) {
|
||||
$post->format_content = wp_get_attachment_image( $meta['image'], $attached_size );
|
||||
$post->format_content = sprintf( $link_fmt, wp_get_attachment_image( $meta['image'], $attached_size ) );
|
||||
return $post->format_content;
|
||||
}
|
||||
|
||||
@ -2412,8 +2417,11 @@ function get_the_post_format_image( $attached_size = 'full', &$post = null ) {
|
||||
|
||||
$urls = array();
|
||||
foreach ( $sizes as $size ) {
|
||||
$urls[] = reset( wp_get_attachment_image_src( $media->ID, $size ) );
|
||||
$urls[] = get_attachment_link( $media->ID );
|
||||
$image = wp_get_attachment_image_src( $media->ID, $size );
|
||||
if ( $image ) {
|
||||
$urls[] = reset( $image );
|
||||
$urls[] = get_attachment_link( $media->ID );
|
||||
}
|
||||
}
|
||||
|
||||
$count = 1;
|
||||
@ -2443,7 +2451,8 @@ function get_the_post_format_image( $attached_size = 'full', &$post = null ) {
|
||||
}
|
||||
|
||||
$post->split_content = $content;
|
||||
$post->format_content = wp_get_attachment_image( $media->ID, $attached_size );
|
||||
$image = wp_get_attachment_image( $media->ID, $attached_size );
|
||||
$post->format_content = sprintf( $link_fmt, $image );
|
||||
return $post->format_content;
|
||||
}
|
||||
|
||||
@ -2452,7 +2461,7 @@ function get_the_post_format_image( $attached_size = 'full', &$post = null ) {
|
||||
if ( ! empty( $htmls ) ) {
|
||||
$html = reset( $htmls );
|
||||
$post->split_content = $content;
|
||||
$post->format_content = $html;
|
||||
$post->format_content = sprintf( $link_fmt, $html );
|
||||
return $post->format_content;
|
||||
}
|
||||
}
|
||||
|
@ -707,7 +707,7 @@ function get_the_post_format_url( $id = 0 ) {
|
||||
if ( empty( $post ) )
|
||||
return '';
|
||||
|
||||
if ( in_array( get_post_format( $post->ID ), array( 'link', 'quote' ) ) ) {
|
||||
if ( in_array( get_post_format( $post->ID ), array( 'image', 'link', 'quote' ) ) ) {
|
||||
$meta = get_post_format_meta( $post->ID );
|
||||
if ( ! empty( $meta['url'] ) )
|
||||
return apply_filters( 'get_the_post_format_url', esc_url_raw( $meta['url'] ), $post );
|
||||
|
Loading…
x
Reference in New Issue
Block a user