diff --git a/wp-admin/css/wp-admin.css b/wp-admin/css/wp-admin.css index 7cf5a04b44..f695a652c8 100644 --- a/wp-admin/css/wp-admin.css +++ b/wp-admin/css/wp-admin.css @@ -3983,7 +3983,9 @@ body .ui-tooltip { 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; padding: 55px 0 20px; } @@ -4012,7 +4014,9 @@ body .ui-tooltip { 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; } diff --git a/wp-includes/media.php b/wp-includes/media.php index 97135e7766..745ed4768e 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -1845,9 +1845,10 @@ function get_attached_video( $post_id = 0 ) { * @param string $content A string which might contain media data. * @param boolean $html Whether to return HTML or URLs * @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 */ -function get_content_media( $type, &$content, $html = true, $remove = false ) { +function get_content_media( $type, &$content, $html = true, $remove = false, $limit = 0 ) { $items = array(); $matches = array(); @@ -1859,6 +1860,8 @@ function get_content_media( $type, &$content, $html = true, $remove = false ) { $content =& str_replace( $shortcode[0], '', $content, $count ); $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 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 */ -function get_the_post_format_media( $type, &$post = null ) { +function get_the_post_format_media( $type, &$post = null, $limit = 0 ) { global $wp_embed; 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 $content = $post->post_content; - $htmls = get_content_media( $type, $content, true, true ); + $htmls = get_content_media( $type, $content, true, true, $limit ); if ( ! empty( $htmls ) ) { $html = reset( $htmls ); $post->split_content = $content; @@ -2133,7 +2137,8 @@ function get_the_post_format_media( $type, &$post = null ) { * */ 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 @@ -2142,7 +2147,8 @@ function the_post_format_video() { * */ function the_post_format_audio() { - echo get_the_post_format_media( 'audio' ); + $null = null; + echo get_the_post_format_media( 'audio', $null, 1 ); } /** diff --git a/wp-includes/query.php b/wp-includes/query.php index e42404ce68..3b41af4c77 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -3702,12 +3702,12 @@ function setup_postdata($post) { $split_content = $post->split_content; break; case 'audio': - get_the_post_format_media( 'audio', $post ); + get_the_post_format_media( 'audio', $post, 1 ); if ( isset( $post->split_content ) ) $split_content = $post->split_content; break; case 'video': - get_the_post_format_media( 'video', $post ); + get_the_post_format_media( 'video', $post, 1 ); if ( isset( $post->split_content ) ) $split_content = $post->split_content; break;