Make WordPress Core

Changeset 24078


Ignore:
Timestamp:
04/25/2013 02:18:49 AM (13 years ago)
Author:
markjaquith
Message:

Fix mangled image output in compat function.

props wonderboymusic. see #24175.

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/media.php

    r24066 r24078  
    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 ' ) ) {
  • trunk/wp-includes/post-formats.php

    r24075 r24078  
    375375                case 'image':
    376376                        if ( ! empty( $meta['image'] ) ) {
    377                                 $image = is_numeric( $meta['image'] ) ? wp_get_attachment_url( $meta['image'] ) : $meta['image'];
    378 
    379                                 if ( ! empty( $image ) && ! stristr( $content, $image ) ) {
    380                                         if ( false === strpos( $image, '<a ' ) ) {
    381                                                 $image_html = sprintf(
     377
     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'] ) ),
     397                                                        esc_url( $meta['image'] )
     398                                                );
     399                                        } else {
     400                                                // assume HTML
     401                                                $image = $meta['image'];
     402                                        }
     403
     404                                        if ( ! empty( $meta['url'] ) && false === strpos( $image, '<a ' ) ) {
     405                                                $format_output .= sprintf(
     406                                                        '<a href="%s">%s</a>',
     407                                                        esc_url( $meta['url'] ),
    384408                                                        $image
    385409                                                );
    386410                                        } else {
    387                                                 $image_html = $image;
    388                                         }
    389 
    390                                         if ( empty( $meta['url'] ) || false !== strpos( $image, '<a ' ) ) {
    391                                                 $format_output .= $image_html;
    392                                         } else {
    393                                                 $format_output .= sprintf(
    394                                                         '<a href="%s">%s</a>',
    395                                                         esc_url( $meta['url'] ),
    396                                                         $image_html
    397                                                 );
     411                                                $format_output .= $image;
    398412                                        }
    399413                                }
Note: See TracChangeset for help on using the changeset viewer.