Only remove ONE piece of media from the content in setup_postdata().

props wonderboymusic. fixes #24052.

git-svn-id: http://core.svn.wordpress.org/trunk@23984 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Mark Jaquith 2013-04-14 01:11:44 +00:00
parent ce42190a4c
commit 697bf3d70e
3 changed files with 19 additions and 9 deletions

View File

@ -3983,7 +3983,9 @@ body .ui-tooltip {
background: #f5f5f5 url(../images/media-button-2x.png) no-repeat 50% 25%; background: #f5f5f5 url(../images/media-button-2x.png) no-repeat 50% 25%;
} }
.wp-format-media-holder.empty { .wp-format-media-holder.empty,
.wp-format-audio .wp-format-media-holder,
.wp-format-video .wp-format-media-holder {
height: auto; height: auto;
padding: 55px 0 20px; padding: 55px 0 20px;
} }
@ -4012,7 +4014,9 @@ body .ui-tooltip {
max-height: 100%; max-height: 100%;
} }
.empty .wp-format-media-select { .empty .wp-format-media-select,
.wp-format-audio .wp-format-media-select,
.wp-format-video .wp-format-media-select {
height: 20px; height: 20px;
} }

View File

@ -1845,9 +1845,10 @@ function get_attached_video( $post_id = 0 ) {
* @param string $content A string which might contain media data. * @param string $content A string which might contain media data.
* @param boolean $html Whether to return HTML or URLs * @param boolean $html Whether to return HTML or URLs
* @param boolean $remove Whether to remove the found URL from the passed content. * @param boolean $remove Whether to remove the found URL from the passed content.
* @param int $limit Optional. The number of medias to return
* @return array A list of parsed shortcodes or extracted srcs * @return array A list of parsed shortcodes or extracted srcs
*/ */
function get_content_media( $type, &$content, $html = true, $remove = false ) { function get_content_media( $type, &$content, $html = true, $remove = false, $limit = 0 ) {
$items = array(); $items = array();
$matches = array(); $matches = array();
@ -1859,6 +1860,8 @@ function get_content_media( $type, &$content, $html = true, $remove = false ) {
$content =& str_replace( $shortcode[0], '', $content, $count ); $content =& str_replace( $shortcode[0], '', $content, $count );
$items[] = do_shortcode_tag( $shortcode ); $items[] = do_shortcode_tag( $shortcode );
if ( $limit > 0 && count( $items ) >= $limit )
break;
} }
} }
} }
@ -2043,9 +2046,10 @@ wp_embed_register_handler( 'wp_video_embed', '#https?://.+?\.(' . join( '|', wp_
* *
* @param string $type Required. 'audio' or 'video' * @param string $type Required. 'audio' or 'video'
* @param WP_Post $post Optional. Used instead of global $post when passed. * @param WP_Post $post Optional. Used instead of global $post when passed.
* @param int $limit Optional. The number of medias to remove if content is scanned.
* @return string * @return string
*/ */
function get_the_post_format_media( $type, &$post = null ) { function get_the_post_format_media( $type, &$post = null, $limit = 0 ) {
global $wp_embed; global $wp_embed;
if ( empty( $post ) ) if ( empty( $post ) )
@ -2090,7 +2094,7 @@ function get_the_post_format_media( $type, &$post = null ) {
// these functions expect a reference, so we should make a copy of post content to avoid changing it // these functions expect a reference, so we should make a copy of post content to avoid changing it
$content = $post->post_content; $content = $post->post_content;
$htmls = get_content_media( $type, $content, true, true ); $htmls = get_content_media( $type, $content, true, true, $limit );
if ( ! empty( $htmls ) ) { if ( ! empty( $htmls ) ) {
$html = reset( $htmls ); $html = reset( $htmls );
$post->split_content = $content; $post->split_content = $content;
@ -2133,7 +2137,8 @@ function get_the_post_format_media( $type, &$post = null ) {
* *
*/ */
function the_post_format_video() { function the_post_format_video() {
echo get_the_post_format_media( 'video' ); $null = null;
echo get_the_post_format_media( 'video', $null, 1 );
} }
/** /**
* Output the first audio in the current (@global) post's content * Output the first audio in the current (@global) post's content
@ -2142,7 +2147,8 @@ function the_post_format_video() {
* *
*/ */
function the_post_format_audio() { function the_post_format_audio() {
echo get_the_post_format_media( 'audio' ); $null = null;
echo get_the_post_format_media( 'audio', $null, 1 );
} }
/** /**

View File

@ -3702,12 +3702,12 @@ function setup_postdata($post) {
$split_content = $post->split_content; $split_content = $post->split_content;
break; break;
case 'audio': case 'audio':
get_the_post_format_media( 'audio', $post ); get_the_post_format_media( 'audio', $post, 1 );
if ( isset( $post->split_content ) ) if ( isset( $post->split_content ) )
$split_content = $post->split_content; $split_content = $post->split_content;
break; break;
case 'video': case 'video':
get_the_post_format_media( 'video', $post ); get_the_post_format_media( 'video', $post, 1 );
if ( isset( $post->split_content ) ) if ( isset( $post->split_content ) )
$split_content = $post->split_content; $split_content = $post->split_content;
break; break;