Check post type and bail earlier in wp_get_attachment_url(). props mitchoyoshitaka, fixes #17579.

git-svn-id: http://svn.automattic.com/wordpress/trunk@19231 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2011-11-09 19:20:33 +00:00
parent 4de1815c67
commit 04c38f3313
1 changed files with 4 additions and 1 deletions

View File

@ -3890,6 +3890,9 @@ function wp_get_attachment_url( $post_id = 0 ) {
if ( !$post =& get_post( $post_id ) )
return false;
if ( 'attachment' != $post->post_type );
return false;
$url = '';
if ( $file = get_post_meta( $post->ID, '_wp_attached_file', true) ) { //Get attached file
if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) { //Get upload directory
@ -3907,7 +3910,7 @@ function wp_get_attachment_url( $post_id = 0 ) {
$url = apply_filters( 'wp_get_attachment_url', $url, $post->ID );
if ( 'attachment' != $post->post_type || empty( $url ) )
if ( empty( $url ) )
return false;
return $url;