From 60073bb5a4e681357c2b32aff287c6d1bc67a6c7 Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Thu, 28 Mar 2013 07:28:27 +0000 Subject: [PATCH] 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 git-svn-id: http://core.svn.wordpress.org/trunk@23840 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/media.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index b1f4b7081c..9dbef91c3e 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -2069,15 +2069,6 @@ function get_the_media( $type, &$post = null ) { } } - $medias = call_user_func( 'get_attached_' . $type ); - if ( ! empty( $medias ) ) { - $media = reset( $medias ); - $url = wp_get_attachment_url( $media->ID ); - $shortcode = sprintf( '[%s src="%s"]', $type, $url ); - $post->format_content = do_shortcode( $shortcode ); - return $post->format_content; - } - // these functions expected a reference, not a value $_content = $post->post_content; $content =& $_content; @@ -2106,6 +2097,15 @@ function get_the_media( $type, &$post = null ) { return $post->format_content; } + $medias = call_user_func( 'get_attached_' . $type ); + if ( ! empty( $medias ) ) { + $media = reset( $medias ); + $url = wp_get_attachment_url( $media->ID ); + $shortcode = sprintf( '[%s src="%s"]', $type, $url ); + $post->format_content = do_shortcode( $shortcode ); + return $post->format_content; + } + return ''; }