Make WordPress Core

Opened 11 months ago

Last modified 3 months ago

#52840 accepted enhancement

Include filesize information in REST API response for all media types

Reported by: tfrommen Owned by: rachelbaker
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: REST API Keywords: has-patch needs-unit-tests
Focuses: rest-api Cc:


Requesting the /media REST API endpoint, only audio attachments include filesize information in the response data (in media_details->filesize).

I suggest to check for each item if filesize is present, or else fill it in using the actual file. This would be pretty much in line with what is done in wp_prepare_attachment_for_js.

Making the information available locally, when creating the response data, is much more performant than having to request the file in one or more follow-up requests.

Attachments (2)

52840.diff (827 bytes) - added by tfrommen 11 months ago.
52840.1.diff (819 bytes) - added by tfrommen 11 months ago.

Download all attachments as: .zip

Change History (9)

11 months ago

11 months ago


#1 @rachelbaker
10 months ago

  • Keywords needs-unit-tests added
  • Milestone changed from Awaiting Review to 5.8
  • Owner set to rachelbaker
  • Status changed from new to accepted

This ticket was mentioned in Slack in #core-media by spacedmonkey. View the logs.

9 months ago

#3 @desrosj
8 months ago

  • Milestone changed from 5.8 to 5.9

Today is 5.8 feature freeze. Unfortunately this one ran out of time.

Punting to 5.9 as there has been good recent momentum.

This ticket was mentioned in Slack in #core-restapi by spacedmonkey. View the logs.

4 months ago

#6 @spacedmonkey
4 months ago

This ticket was discussed in this week's REST API meeting.

In short, making filesize calls in the rest api, will likely come with some overhead. For example those storing files on NFS or S3, will like need to ping an external resource to get file information, slowing down the response.

Until file sizes are "cached" somehow ( see #49412 ), this ticket should be marked as blocked.

#7 @TimothyBlynJacobs
3 months ago

  • Milestone changed from 5.9 to Future Release

Moving to Future Release based off comment:6.

Note: See TracTickets for help on using tickets.