From 4a480146c0218c86d9baad8ba12bab9f3fb4cdf8 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 2 Jul 2014 14:36:29 +0000 Subject: [PATCH] Avoing a PHP warning in media modal if the attached file does not exist. props kovshenin. see #24716. git-svn-id: https://develop.svn.wordpress.org/trunk@28959 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/media.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index e208c52ee3..1efa375ca3 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -2631,9 +2631,12 @@ function wp_prepare_attachment_for_js( $attachment ) { $response['uploadedToTitle'] = $post_parent->post_title ? $post_parent->post_title : __( '(No title)' ); } - $bytes = filesize( get_attached_file( $attachment->ID ) ); - $response['filesizeInBytes'] = $bytes; - $response['filesizeHumanReadable'] = size_format( $bytes ); + $attached_file = get_attached_file( $attachment->ID ); + if ( file_exists( $attached_file ) ) { + $bytes = filesize( $attached_file ); + $response['filesizeInBytes'] = $bytes; + $response['filesizeHumanReadable'] = size_format( $bytes ); + } if ( current_user_can( 'edit_post', $attachment->ID ) ) { $response['nonces']['update'] = wp_create_nonce( 'update-post_' . $attachment->ID );