Make WordPress Core

Changeset 23840


Ignore:
Timestamp:
03/28/2013 07:28:27 AM (12 years ago)
Author:
markjaquith
Message:

Move the "look for the first media attachment" code below the "look
in the post content for media" code, so that it is the method of last
resort. This way, if you attach AND embed media, you won't get duplication.

fixes #23879

File:
1 edited

Legend:

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

    r23821 r23840  
    20702070    }
    20712071
    2072     $medias = call_user_func( 'get_attached_' . $type );
    2073     if ( ! empty( $medias ) ) {
    2074         $media = reset( $medias );
    2075         $url = wp_get_attachment_url( $media->ID );
    2076         $shortcode = sprintf( '[%s src="%s"]', $type, $url );
    2077         $post->format_content = do_shortcode( $shortcode );
    2078         return $post->format_content;
    2079     }
    2080 
    20812072    // these functions expected a reference, not a value
    20822073    $_content = $post->post_content;
     
    21072098    }
    21082099
     2100    $medias = call_user_func( 'get_attached_' . $type );
     2101    if ( ! empty( $medias ) ) {
     2102        $media = reset( $medias );
     2103        $url = wp_get_attachment_url( $media->ID );
     2104        $shortcode = sprintf( '[%s src="%s"]', $type, $url );
     2105        $post->format_content = do_shortcode( $shortcode );
     2106        return $post->format_content;
     2107    }
     2108
    21092109    return '';
    21102110}
Note: See TracChangeset for help on using the changeset viewer.