Make WordPress Core


Ignore:
Timestamp:
04/14/2013 01:11:44 AM (13 years ago)
Author:
markjaquith
Message:

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

props wonderboymusic. fixes #24052.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/media.php

    r23969 r23984  
    18461846 * @param boolean $html Whether to return HTML or URLs
    18471847 * @param boolean $remove Whether to remove the found URL from the passed content.
     1848 * @param int $limit Optional. The number of medias to return
    18481849 * @return array A list of parsed shortcodes or extracted srcs
    18491850 */
    1850 function get_content_media( $type, &$content, $html = true, $remove = false ) {
     1851function get_content_media( $type, &$content, $html = true, $remove = false, $limit = 0 ) {
    18511852    $items = array();
    18521853    $matches = array();
     
    18601861
    18611862                $items[] = do_shortcode_tag( $shortcode );
     1863                if ( $limit > 0 && count( $items ) >= $limit )
     1864                    break;
    18621865            }
    18631866        }
     
    20442047 * @param string $type Required. 'audio' or 'video'
    20452048 * @param WP_Post $post Optional. Used instead of global $post when passed.
     2049 * @param int $limit Optional. The number of medias to remove if content is scanned.
    20462050 * @return string
    20472051 */
    2048 function get_the_post_format_media( $type, &$post = null ) {
     2052function get_the_post_format_media( $type, &$post = null, $limit = 0 ) {
    20492053    global $wp_embed;
    20502054
     
    20912095    $content = $post->post_content;
    20922096
    2093     $htmls = get_content_media( $type, $content, true, true );
     2097    $htmls = get_content_media( $type, $content, true, true, $limit );
    20942098    if ( ! empty( $htmls ) ) {
    20952099        $html = reset( $htmls );
     
    21342138 */
    21352139function the_post_format_video() {
    2136     echo get_the_post_format_media( 'video' );
     2140    $null = null;
     2141    echo get_the_post_format_media( 'video', $null, 1 );
    21372142}
    21382143/**
     
    21432148 */
    21442149function the_post_format_audio() {
    2145     echo get_the_post_format_media( 'audio' );
     2150    $null = null;
     2151    echo get_the_post_format_media( 'audio', $null, 1 );
    21462152}
    21472153
Note: See TracChangeset for help on using the changeset viewer.