Avoing a PHP warning in media modal if the attached file does not exist.

props kovshenin.
see #24716.
Built from https://develop.svn.wordpress.org/trunk@28959


git-svn-id: http://core.svn.wordpress.org/trunk@28755 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2014-07-02 14:37:15 +00:00
parent f84ef60b52
commit 428a83259e

View File

@ -2631,9 +2631,12 @@ function wp_prepare_attachment_for_js( $attachment ) {
$response['uploadedToTitle'] = $post_parent->post_title ? $post_parent->post_title : __( '(No title)' ); $response['uploadedToTitle'] = $post_parent->post_title ? $post_parent->post_title : __( '(No title)' );
} }
$bytes = filesize( get_attached_file( $attachment->ID ) ); $attached_file = get_attached_file( $attachment->ID );
$response['filesizeInBytes'] = $bytes; if ( file_exists( $attached_file ) ) {
$response['filesizeHumanReadable'] = size_format( $bytes ); $bytes = filesize( $attached_file );
$response['filesizeInBytes'] = $bytes;
$response['filesizeHumanReadable'] = size_format( $bytes );
}
if ( current_user_can( 'edit_post', $attachment->ID ) ) { if ( current_user_can( 'edit_post', $attachment->ID ) ) {
$response['nonces']['update'] = wp_create_nonce( 'update-post_' . $attachment->ID ); $response['nonces']['update'] = wp_create_nonce( 'update-post_' . $attachment->ID );