Fix mangled image output in compat function.

props wonderboymusic. see #24175.

git-svn-id: http://core.svn.wordpress.org/trunk@24078 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Mark Jaquith 2013-04-25 02:18:49 +00:00
parent 5f08d11b11
commit cd0bbd830c
2 changed files with 25 additions and 11 deletions

View File

@ -2428,7 +2428,7 @@ function get_the_post_format_image( $attached_size = 'full', &$post = null ) {
// wrap image in <a>
if ( ! empty( $meta['url'] ) )
$image = sprint( $link_fmt, $image );
} elseif ( has_shortcode( $meta['image'], 'gallery' ) ) {
} elseif ( has_shortcode( $meta['image'], 'caption' ) ) {
// wrap <img> in <a>
if ( ! empty( $meta['url'] ) && false === strpos( $meta['image'], '<a ' ) ) {
$meta['image'] = preg_replace(

View File

@ -374,27 +374,41 @@ function post_formats_compat( $content, $id = 0 ) {
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 ) ) {
if ( false === strpos( $image, '<a ' ) ) {
$image_html = sprintf(
if ( has_shortcode( $meta['image'], 'caption' ) ) {
// wrap <img> in <a>
if ( ! empty( $meta['url'] ) && false === strpos( $meta['image'], '<a ' ) ) {
$meta['image'] = preg_replace(
'#(<img[^>]+>)#',
sprintf( '<a href="%s">$1</a>', esc_url( $meta['url'] ) ),
$meta['image']
);
}
$format_output .= do_shortcode( $meta['image'] );
} else {
if ( is_numeric( $meta['image'] ) ) {
$image = wp_get_attachment_image( absint( $meta['image'] ), 'full' );
} elseif ( ! preg_match( '#<[^>]+>#', $meta['image'] ) ) {
// not HTML, assume URL
$image = sprintf(
'<img %ssrc="%s" alt="" />',
empty( $compat['image_class'] ) ? '' : sprintf( 'class="%s" ', esc_attr( $compat['image_class'] ) ),
$image
esc_url( $meta['image'] )
);
} else {
$image_html = $image;
// assume HTML
$image = $meta['image'];
}
if ( empty( $meta['url'] ) || false !== strpos( $image, '<a ' ) ) {
$format_output .= $image_html;
} else {
if ( ! empty( $meta['url'] ) && false === strpos( $image, '<a ' ) ) {
$format_output .= sprintf(
'<a href="%s">%s</a>',
esc_url( $meta['url'] ),
$image_html
$image
);
} else {
$format_output .= $image;
}
}
}