Drop get_images_in_content() and get_image_in_content(), until recently get_content_image(s)(). fixes #24202.

git-svn-id: http://core.svn.wordpress.org/trunk@24685 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-07-12 20:34:07 +00:00
parent 75ab12808b
commit 769e3e9b5d
1 changed files with 0 additions and 73 deletions

View File

@ -1892,79 +1892,6 @@ function get_media_embedded_in_content( $content, $types = null ) {
return $html; return $html;
} }
/**
* Check the content blob for images or image srcs
*
* @since 3.6.0
*
* @param string $content A string which might contain image data.
* @param boolean $html Whether to return HTML or URLs in the array
* @return array The found images or srcs
*/
function get_images_in_content( $content, $html = true ) {
$tags = array();
$captions = array();
if ( preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ) ) {
foreach ( $matches as $shortcode ) {
if ( 'caption' === $shortcode[2] ) {
$captions[] = $shortcode[0];
if ( $html )
$tags[] = do_shortcode_tag( $shortcode );
}
}
}
foreach ( array( 'a', 'img' ) as $tag ) {
if ( preg_match_all( '#' . get_tag_regex( $tag ) . '#i', $content, $matches, PREG_SET_ORDER ) ) {
foreach ( $matches as $node ) {
if ( ! strstr( $node[0], '<img ' ) )
continue;
$count = 1;
$found = false;
foreach ( $captions as $caption ) {
if ( strstr( $caption, $node[0] ) ) {
$found = true;
}
}
if ( ! $found )
$tags[] = $node[0];
}
}
}
if ( $html )
return $tags;
$image_srcs = array();
foreach ( $tags as $tag ) {
preg_match( '#src=([\'"])(.+?)\1#is', $tag, $src );
if ( ! empty( $src[2] ) )
$image_srcs[] = $src[2];
}
$image_srcs = array_values( array_unique( $image_srcs ) );
return apply_filters( 'get_images_in_content', $image_srcs, $content );
}
/**
* Check the content blob for images or srcs and return the first
*
* @since 3.6.0
*
* @param string $content A string which might contain image data.
* @param boolean $html Whether to return HTML or URLs
* @return string The found data
*/
function get_image_in_content( $content, $html = true ) {
$srcs = get_images_from_content( $content, $html );
return apply_filters( 'get_image_in_content', reset( $srcs ), $content );
}
/** /**
* Retrieve galleries from the passed post's content * Retrieve galleries from the passed post's content
* *