Add compat code for 'image' post format.
see #19570. props wonderboymusic. git-svn-id: http://core.svn.wordpress.org/trunk@23847 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2840f02efc
commit
22b45b2fbb
|
@ -118,7 +118,7 @@ window.wp = window.wp || {};
|
|||
mediaPreview('video', url, mime);
|
||||
} else {
|
||||
// set the hidden input's value
|
||||
$field.val(url);
|
||||
$field.val(id);
|
||||
// Show the image in the placeholder
|
||||
$el.html('<img src="' + url + '" />');
|
||||
$holder.removeClass('empty').show();
|
||||
|
|
|
@ -2367,6 +2367,12 @@ function get_the_image( $attached_size = 'full', &$post = null ) {
|
|||
if ( isset( $post->format_content ) )
|
||||
return $post->format_content;
|
||||
|
||||
$meta = get_post_format_meta( $post->ID );
|
||||
if ( ! empty( $meta['image'] ) ) {
|
||||
$post->format_content = wp_get_attachment_image( $meta['image'], $attached_size );
|
||||
return $post->format_content;
|
||||
}
|
||||
|
||||
$medias = get_attached_images();
|
||||
if ( ! empty( $medias ) ) {
|
||||
$media = reset( $medias );
|
||||
|
|
|
@ -289,7 +289,7 @@ function post_formats_compat( $content, $id = 0 ) {
|
|||
return $content;
|
||||
|
||||
$format = get_post_format( $post );
|
||||
if ( empty( $format ) || in_array( $format, array( 'status', 'aside', 'chat' ) ) )
|
||||
if ( empty( $format ) || in_array( $format, array( 'status', 'aside', 'chat', 'gallery' ) ) )
|
||||
return $content;
|
||||
|
||||
if ( current_theme_supports( 'structured-post-formats', $format ) )
|
||||
|
@ -308,8 +308,6 @@ function post_formats_compat( $content, $id = 0 ) {
|
|||
$show_content = true;
|
||||
$format_output = '';
|
||||
$meta = get_post_format_meta( $post->ID );
|
||||
// passed by ref in preg_match()
|
||||
$matches = array();
|
||||
|
||||
switch ( $format ) {
|
||||
case 'link':
|
||||
|
@ -341,11 +339,34 @@ function post_formats_compat( $content, $id = 0 ) {
|
|||
}
|
||||
break;
|
||||
|
||||
case 'image':
|
||||
if ( ! empty( $meta['image'] ) ) {
|
||||
$image = is_numeric( $meta['image'] ) ? wp_get_attachment_url( $meta['image'] ) : $meta['image'];
|
||||
|
||||
if ( ! empty( $image ) && ! stristr( $content, $image ) ) {
|
||||
$image_html = sprintf(
|
||||
'<img %ssrc="%s" alt="" />',
|
||||
empty( $compat['image_class'] ) ? '' : sprintf( 'class="%s" ', esc_attr( $compat['image_class'] ) ),
|
||||
$image
|
||||
);
|
||||
if ( empty( $meta['url'] ) ) {
|
||||
$format_output .= $image_html;
|
||||
} else {
|
||||
$format_output .= sprintf(
|
||||
'<a href="%s">%s</a>',
|
||||
esc_url( $meta['url'] ),
|
||||
$image_html
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'quote':
|
||||
if ( ! empty( $meta['quote'] ) && ! stristr( $content, $meta['quote'] ) ) {
|
||||
$quote = sprintf( '<blockquote>%s</blockquote>', wpautop( $meta['quote'] ) );
|
||||
if ( ! empty( $meta['quote_source'] ) ) {
|
||||
$source = ( empty( $quote_meta['url'] ) ) ? $meta['quote_source'] : sprintf( '<a href="%s">%s</a>', esc_url( $meta['url'] ), $meta['quote_source'] );
|
||||
$source = ( empty( $meta['url'] ) ) ? $meta['quote_source'] : sprintf( '<a href="%s">%s</a>', esc_url( $meta['url'] ), $meta['quote_source'] );
|
||||
$quote .= sprintf( '<figcaption class="quote-caption">%s</figcaption>', $source );
|
||||
}
|
||||
$format_output .= sprintf( '<figure class="quote">%s</figure>', $quote );
|
||||
|
|
Loading…
Reference in New Issue