Media: In wp_prepare_attachment_for_js(), don't call file_exists() and filesize() to retrieve $bytes if the data is already present in $meta. This is how the same code in attachment_submitbox_metadata() already works.

Props polevaultweb.
Fixes #33214.


git-svn-id: https://develop.svn.wordpress.org/trunk@34258 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2015-09-17 05:02:52 +00:00
parent 79656b5fdd
commit 2e7277b733

View File

@ -2778,8 +2778,16 @@ function wp_prepare_attachment_for_js( $attachment ) {
}
$attached_file = get_attached_file( $attachment->ID );
if ( file_exists( $attached_file ) ) {
if ( isset( $meta['filesize'] ) ) {
$bytes = $meta['filesize'];
} elseif ( file_exists( $attached_file ) ) {
$bytes = filesize( $attached_file );
} else {
$bytes = '';
}
if ( $bytes ) {
$response['filesizeInBytes'] = $bytes;
$response['filesizeHumanReadable'] = size_format( $bytes );
}