diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
index ea4ae947cc..aca5517ac6 100644
a
|
b
|
public function prepare_item_for_response( $post, $request ) { |
788 | 788 | } else { |
789 | 789 | $data['media_details']['sizes'] = new stdClass; |
790 | 790 | } |
| 791 | |
| 792 | if ( ! isset( $data['media_details']['filesize'] ) ) { |
| 793 | $attached_file = get_attached_file( $post->ID ); |
| 794 | if ( is_readable( $attached_file ) ) { |
| 795 | $data['media_details']['filesize'] = filesize( $attached_file ); |
| 796 | } |
| 797 | } |
| 798 | |
791 | 799 | } |
792 | 800 | |
793 | 801 | if ( in_array( 'post', $fields, true ) ) { |