Make WordPress Core

Ticket #52840: 52840.diff

File 52840.diff, 827 bytes (added by tfrommen, 3 years ago)
  • src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

    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 ) { 
    788788                        } else {
    789789                                $data['media_details']['sizes'] = new stdClass;
    790790                        }
     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                       
    791799                }
    792800
    793801                if ( in_array( 'post', $fields, true ) ) {