Add compat code for 'image' post format.

see #19570. props wonderboymusic.

git-svn-id: https://develop.svn.wordpress.org/trunk@23847 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith 2013-03-29 05:21:23 +00:00
parent fc753f9803
commit fe4da10a48
3 changed files with 32 additions and 5 deletions

View File

@ -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();

View File

@ -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 );

View File

@ -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 );