WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 9 months ago

#41692 new defect (bug)

REST API does not return featured_media for Audio/Video

Reported by: wonderboymusic Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: REST API Keywords: has-patch needs-refresh
Focuses: Cc:
PR Number:

Description

Audio and Video attachments can have a featured image. This data is not currently returned by the REST API wp/v2/media endpoint. Part of the problem is that the schema for attachments is generated by the Post controller, even though the Post controller does not return data for attachments. Because the schema is used by the OPTIONS endpoint, before knowing what mime-type the attachment is, thumbnail should be set for attachment's attributes so that featured_media is added to the responses from wp/v2/media.

Attachments (2)

rest-thumbnail.diff (1.4 KB) - added by wonderboymusic 2 years ago.
41692.2.diff (6.9 KB) - added by TimothyBlynJacobs 2 years ago.

Download all attachments as: .zip

Change History (17)

#1 @rmccue
2 years ago

Makes sense to me.

On the patch, is there a reason to explicitly set featured_media? It looks to me like setting in the schema should be enough to add it to the response.

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


2 years ago

#3 @TimothyBlynJacobs
2 years ago

Taking a look at this after discussion in the REST API bug scrub Friday.

Core doesn't register the attachment post type with support for thumbnail. So just including thumbnail in the fixed schema is causes issues with the ::check_post_data() unit test method.

The first patch lists featured_media in the schema as read-write, but it only supports read. This is because the attachments controller doesn't call parent::create_item() which has the support for setting the featured media.

So that leaves us with three options I think.

  1. Add thumbnail support for the attachments post type and manually update the thumbnail in the attachments controller. I've attached the patch that does this. I have no idea what the ramifications are for listing thumbnail as supported in the post type, though.
  2. Same as #1, except don't include thumbnail support in the attachment post type and update ::check_post_data to either use the schema instead of post_type_supports() or just make an exception for the attachment post type.
  3. Continue with the first patch, but mark the featured media schema as readonly.

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


2 years ago

#5 @kadamwhite
2 years ago

  • Milestone changed from 4.9 to Future Release

Punting to future release, per discussion with @TimothyBlynJacobs in this week's REST API team chat

#6 @wonderboymusic
2 years ago

  • Milestone changed from Future Release to 5.0

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


19 months ago

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


12 months ago

#9 @desrosj
12 months ago

  • Milestone changed from 5.0 to 5.1

Punting as this falls outside the scope for 5.0.

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


9 months ago

#11 @desrosj
9 months ago

  • Keywords needs-refresh added

41692.2.diff is no longer applying to trunk

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


9 months ago

#13 @desrosj
9 months ago

Per today's bug scrub, @TimothyBlynJacobs will refresh the patch. I also dropped this in #core-media for some additional feedback.

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


9 months ago

#15 @pento
9 months ago

  • Milestone changed from 5.1 to Future Release

Patch needs refreshing, punting.

Note: See TracTickets for help on using tickets.