amf-wordpress icon indicating copy to clipboard operation
amf-wordpress copied to clipboard

Add a file size field to the REST API and use its value when fetching media

Open johnbillion opened this issue 4 years ago • 3 comments

This is a follow-up to #6.

The file size is not exposed by default in the WordPress REST API media endpoint. This plugin should add a new field to the REST API which exposes it, and then reads that value in Factory::create() and sets the file size via $item->set_file_size() if the field exists.

This would solve the problem of not having file size information when this plugin is used for sharing media within a Multisite network.

Longer term, we should open a ticket for WordPress core to get the file size added to the REST API too.

johnbillion avatar Mar 16 '21 17:03 johnbillion

Just noting that, for audio files, this information is already present in $data->media_details->filesize. For any other media type, it is not.

tfrommen avatar Mar 17 '21 21:03 tfrommen

Also, I just created https://core.trac.wordpress.org/ticket/52840.

tfrommen avatar Mar 17 '21 21:03 tfrommen

Older issue I know but any change to enable this would have to be in code running on the source site, this plugin won't necessarily be enabled there.

roborourke avatar Jun 18 '21 09:06 roborourke