diff --git wp-includes/functions.php wp-includes/functions.php
index 0afa50b..c10709c 100644
--- wp-includes/functions.php
+++ wp-includes/functions.php
@@ -3985,6 +3985,5 @@ function wp_auth_check( $response, $data ) {
function get_tag_regex( $tag ) {
if ( empty( $tag ) )
return;
-
- return sprintf( '(<%1$s[^>]*(?:/?>$|>[\s\S]*?%1$s>))', tag_escape( $tag ) );
+ return sprintf( '<%1$s[^<]*(?:>[\s\S]*<\/%1$s>|\s*\/>)', tag_escape( $tag ) );
}
diff --git wp-includes/media.php wp-includes/media.php
index bd52867..51a466d 100644
--- wp-includes/media.php
+++ wp-includes/media.php
@@ -1966,7 +1966,7 @@ function get_embedded_media( $type, &$content, $remove = false, $limit = 0 ) {
foreach ( array( $type, 'object', 'embed', 'iframe' ) as $tag ) {
if ( preg_match( '#' . get_tag_regex( $tag ) . '#', $content, $matches ) ) {
- $html[] = $matches[1];
+ $html[] = $matches[0];
if ( $remove )
$content = str_replace( $matches[0], '', $content );
@@ -2209,30 +2209,45 @@ function get_content_images( &$content, $html = true, $remove = false, $limit =
$tags = array();
$captions = array();
- if ( $remove && preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) {
+ if ( preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) {
foreach ( $matches as $shortcode ) {
- if ( 'caption' === $shortcode[2] )
+ if ( 'caption' === $shortcode[2] ) {
$captions[] = $shortcode[0];
+ if ( $html )
+ $tags[] = do_shortcode( $shortcode[0] );
+ }
+
+ if ( $limit > 0 && count( $tags ) >= $limit )
+ break;
}
}
- if ( preg_match_all( '#]+/?>#i', $content, $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) {
- foreach ( $matches as $tag ) {
- $count = 1;
- if ( $remove ) {
+ foreach ( array( 'a', 'img' ) as $tag ) {
+ if ( preg_match_all( '#' . get_tag_regex( $tag ) . '#i', $content, $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) {
+ foreach ( $matches as $node ) {
+ if ( ! strstr( $node[0], ' 0 && count( $tags ) >= $limit )
- break;
+ if ( $limit > 0 && count( $tags ) >= $limit )
+ break 2;
+ }
}
}
@@ -2400,6 +2415,7 @@ function get_the_post_format_image( $attached_size = 'full', &$post = null ) {
if ( isset( $post->format_content ) )
return $post->format_content;
+ $matched = false;
$meta = get_post_format_meta( $post->ID );
$link_fmt = '%s';
@@ -2426,7 +2442,7 @@ function get_the_post_format_image( $attached_size = 'full', &$post = null ) {
$sizes = get_intermediate_image_sizes();
$sizes[] = 'full'; // Add original image source.
- $urls = array();
+ $urls = array( get_attachment_link( $media->ID ) );
foreach ( $sizes as $size ) {
$image = wp_get_attachment_image_src( $media->ID, $size );
if ( $image )
@@ -2444,8 +2460,11 @@ function get_the_post_format_image( $attached_size = 'full', &$post = null ) {
foreach ( $matches as $shortcode ) {
if ( 'caption' === $shortcode[2] ) {
foreach ( $urls as $url ) {
- if ( strstr( $shortcode[0], $url ) )
+ if ( strstr( $shortcode[0], $url ) ) {
+ if ( ! $matched )
+ $matched = do_shortcode( $shortcode[0] );
$content = str_replace( $shortcode[0], '', $content, $count );
+ }
}
}
}
@@ -2455,16 +2474,25 @@ function get_the_post_format_image( $attached_size = 'full', &$post = null ) {
if ( preg_match_all( '#' . get_tag_regex( $tag ) . '#', $content, $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) {
foreach ( $matches as $match ) {
foreach ( $urls as $url ) {
- if ( strstr( $match[0], $url ) )
+ if ( strstr( $match[0], $url ) ) {
+ if ( ! $matched )
+ $matched = $match[0];
$content = str_replace( $match[0], '', $content, $count );
+ }
}
}
}
}
$post->split_content = $content;
- $image = wp_get_attachment_image( $media->ID, $attached_size );
- $post->format_content = sprintf( $link_fmt, $image );
+ if ( ! $matched ) {
+ $image = wp_get_attachment_image( $media->ID, $attached_size );
+ $post->format_content = sprintf( $link_fmt, $image );
+ } else {
+ $post->format_content = $matched;
+ if ( ! empty( $meta['url'] ) && false === stripos( $matched, 'format_content = sprintf( $link_fmt, $matched );
+ }
return $post->format_content;
}
diff --git wp-includes/post-formats.php wp-includes/post-formats.php
index 127d1ef..4301bed 100644
--- wp-includes/post-formats.php
+++ wp-includes/post-formats.php
@@ -380,12 +380,17 @@ function post_formats_compat( $content, $id = 0 ) {
$image = is_numeric( $meta['image'] ) ? wp_get_attachment_url( $meta['image'] ) : $meta['image'];
if ( ! empty( $image ) && ! stristr( $content, $image ) ) {
- $image_html = sprintf(
- '',
- empty( $compat['image_class'] ) ? '' : sprintf( 'class="%s" ', esc_attr( $compat['image_class'] ) ),
- $image
- );
- if ( empty( $meta['url'] ) ) {
+ if ( false === strpos( $image, '',
+ empty( $compat['image_class'] ) ? '' : sprintf( 'class="%s" ', esc_attr( $compat['image_class'] ) ),
+ $image
+ );
+ } else {
+ $image_html = $image;
+ }
+
+ if ( empty( $meta['url'] ) || false !== strpos( $image, '