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
This commit is contained in:
parent
788724989e
commit
60073bb5a4
|
@ -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 '';
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue