Avoid warning when non-existent ID pass to wp_get_attachment_link(). Tidy formatting of wp_get_attachment_link(). Props SergeyBiryukov, Jayjdk. fixes #18491

git-svn-id: http://svn.automattic.com/wordpress/trunk@19210 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2011-11-08 14:08:25 +00:00
parent 4cf30f3410
commit 75e238360a
1 changed files with 12 additions and 13 deletions

View File

@ -1156,7 +1156,7 @@ function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false
$id = intval( $id );
$_post = & get_post( $id );
if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) )
if ( empty( $_post ) || ( 'attachment' != $_post->post_type ) || ! $url = wp_get_attachment_url( $_post->ID ) )
return __( 'Missing Attachment' );
if ( $permalink )
@ -1164,13 +1164,12 @@ function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false
$post_title = esc_attr( $_post->post_title );
if ( $text ) {
if ( $text )
$link_text = esc_attr( $text );
} elseif ( ( is_int($size) && $size != 0 ) or ( is_string($size) && $size != 'none' ) or $size != false ) {
elseif ( ( is_int( $size ) && $size != 0 ) || ( is_string( $size ) && $size != 'none' ) || $size != false )
$link_text = wp_get_attachment_image( $id, $size, $icon );
} else {
else
$link_text = '';
}
if ( trim( $link_text ) == '' )
$link_text = $_post->post_title;