Make WordPress Core

Changeset 23847


Ignore:
Timestamp:
03/29/2013 05:21:23 AM (11 years ago)
Author:
markjaquith
Message:

Add compat code for 'image' post format.

see #19570. props wonderboymusic.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/js/post-formats.js

    r23843 r23847  
    119119            } else {
    120120                // set the hidden input's value
    121                 $field.val(url);
     121                $field.val(id);
    122122                // Show the image in the placeholder
    123123                $el.html('<img src="' + url + '" />');
  • trunk/wp-includes/media.php

    r23843 r23847  
    23682368        return $post->format_content;
    23692369
     2370    $meta = get_post_format_meta( $post->ID );
     2371    if ( ! empty( $meta['image'] ) ) {
     2372        $post->format_content = wp_get_attachment_image( $meta['image'], $attached_size );
     2373        return $post->format_content;
     2374    }
     2375
    23702376    $medias = get_attached_images();
    23712377    if ( ! empty( $medias ) ) {
  • trunk/wp-includes/post-formats.php

    r23843 r23847  
    290290
    291291    $format = get_post_format( $post );
    292     if ( empty( $format ) || in_array( $format, array( 'status', 'aside', 'chat' ) ) )
     292    if ( empty( $format ) || in_array( $format, array( 'status', 'aside', 'chat', 'gallery' ) ) )
    293293        return $content;
    294294
     
    309309    $format_output = '';
    310310    $meta = get_post_format_meta( $post->ID );
    311     // passed by ref in preg_match()
    312     $matches = array();
    313311
    314312    switch ( $format ) {
     
    342340            break;
    343341
     342        case 'image':
     343            if ( ! empty( $meta['image'] ) ) {
     344                $image = is_numeric( $meta['image'] ) ? wp_get_attachment_url( $meta['image'] ) : $meta['image'];
     345
     346                if ( ! empty( $image ) && ! stristr( $content, $image ) ) {
     347                    $image_html = sprintf(
     348                        '<img %ssrc="%s" alt="" />',
     349                        empty( $compat['image_class'] ) ? '' : sprintf( 'class="%s" ', esc_attr( $compat['image_class'] ) ),
     350                        $image
     351                    );
     352                    if ( empty( $meta['url'] ) ) {
     353                        $format_output .= $image_html;
     354                    } else {
     355                        $format_output .= sprintf(
     356                            '<a href="%s">%s</a>',
     357                            esc_url( $meta['url'] ),
     358                            $image_html
     359                        );
     360                    }
     361                }
     362            }
     363            break;
     364
    344365        case 'quote':
    345366            if ( ! empty( $meta['quote'] ) && ! stristr( $content, $meta['quote'] ) ) {
    346367                $quote = sprintf( '<blockquote>%s</blockquote>', wpautop( $meta['quote'] ) );
    347368                if ( ! empty( $meta['quote_source'] ) ) {
    348                     $source = ( empty( $quote_meta['url'] ) ) ? $meta['quote_source'] : sprintf( '<a href="%s">%s</a>', esc_url( $meta['url'] ), $meta['quote_source'] );
     369                    $source = ( empty( $meta['url'] ) ) ? $meta['quote_source'] : sprintf( '<a href="%s">%s</a>', esc_url( $meta['url'] ), $meta['quote_source'] );
    349370                    $quote .= sprintf( '<figcaption class="quote-caption">%s</figcaption>', $source );
    350371                }
Note: See TracChangeset for help on using the changeset viewer.