Make WordPress Core

Ticket #24175: 24175.diff

File 24175.diff, 2.5 KB (added by wonderboymusic, 12 years ago)
  • wp-includes/media.php

    diff --git wp-includes/media.php wp-includes/media.php
    index 09e0630..42a9825 100644
    function get_the_post_format_image( $attached_size = 'full', &$post = null ) { 
    24282428                        // wrap image in <a>
    24292429                        if ( ! empty( $meta['url'] ) )
    24302430                                $image = sprint( $link_fmt, $image );
    2431                 } elseif ( has_shortcode( $meta['image'], 'gallery' ) ) {
     2431                } elseif ( has_shortcode( $meta['image'], 'caption' ) ) {
    24322432                        // wrap <img> in <a>
    24332433                        if ( ! empty( $meta['url'] ) && false === strpos( $meta['image'], '<a ' ) ) {
    24342434                                $meta['image'] = preg_replace(
  • wp-includes/post-formats.php

    diff --git wp-includes/post-formats.php wp-includes/post-formats.php
    index b993183..392f8aa 100644
    function post_formats_compat( $content, $id = 0 ) { 
    374374
    375375                case 'image':
    376376                        if ( ! empty( $meta['image'] ) ) {
    377                                 $image = is_numeric( $meta['image'] ) ? wp_get_attachment_url( $meta['image'] ) : $meta['image'];
    378377
    379                                 if ( ! empty( $image ) && ! stristr( $content, $image ) ) {
    380                                         if ( false === strpos( $image, '<a ' ) ) {
    381                                                 $image_html = sprintf(
     378                                if ( has_shortcode( $meta['image'], 'caption' ) ) {
     379                                        // wrap <img> in <a>
     380                                        if ( ! empty( $meta['url'] ) && false === strpos( $meta['image'], '<a ' ) ) {
     381                                                $meta['image'] = preg_replace(
     382                                                        '#(<img[^>]+>)#',
     383                                                        sprintf( '<a href="%s">$1</a>', esc_url( $meta['url'] ) ),
     384                                                        $meta['image']
     385                                                );
     386                                        }
     387                                        $format_output .= do_shortcode( $meta['image'] );
     388                                } else {
     389
     390                                        if ( is_numeric( $meta['image'] ) ) {
     391                                                $image = wp_get_attachment_image( absint( $meta['image'] ), 'full' );
     392                                        } elseif ( ! preg_match( '#<[^>]+>#', $meta['image'] ) ) {
     393                                                // not HTML, assume URL
     394                                                $image = sprintf(
    382395                                                        '<img %ssrc="%s" alt="" />',
    383396                                                        empty( $compat['image_class'] ) ? '' : sprintf( 'class="%s" ', esc_attr( $compat['image_class'] ) ),
    384                                                         $image
     397                                                        esc_url( $meta['image'] )
    385398                                                );
    386399                                        } else {
    387                                                 $image_html = $image;
     400                                                // assume HTML
     401                                                $image = $meta['image'];
    388402                                        }
    389403
    390                                         if ( empty( $meta['url'] ) || false !== strpos( $image, '<a ' ) ) {
    391                                                 $format_output .= $image_html;
    392                                         } else {
     404                                        if ( ! empty( $meta['url'] ) && false === strpos( $image, '<a ' ) ) {
    393405                                                $format_output .= sprintf(
    394406                                                        '<a href="%s">%s</a>',
    395407                                                        esc_url( $meta['url'] ),
    396                                                         $image_html
     408                                                        $image
    397409                                                );
     410                                        } else {
     411                                                $format_output .= $image;
    398412                                        }
    399413                                }
    400414                        }