Make WordPress Core

Opened 6 years ago

Last modified 3 months ago

#41692 assigned defect (bug)

REST API does not return featured_media for Audio/Video

Reported by: wonderboymusic's profile wonderboymusic Owned by: dlh's profile dlh
Milestone: 6.3 Priority: normal
Severity: normal Version:
Component: REST API Keywords: has-patch needs-refresh
Focuses: Cc:

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 6 years ago.
41692.2.diff (6.9 KB) - added by TimothyBlynJacobs 6 years ago.

Download all attachments as: .zip

Change History (19)

#1 @rmccue
6 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.


6 years ago

#3 @TimothyBlynJacobs
6 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.


6 years ago

#5 @kadamwhite
6 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
6 years ago

  • Milestone changed from Future Release to 5.0

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


5 years ago

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


5 years ago

#9 @desrosj
5 years 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.


4 years ago

#11 @desrosj
4 years 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.


4 years ago

#13 @desrosj
4 years 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.


4 years ago

#15 @pento
4 years ago

  • Milestone changed from 5.1 to Future Release

Patch needs refreshing, punting.

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


3 months ago

#17 @dlh
3 months ago

  • Milestone changed from Future Release to 6.3
  • Owner set to dlh
  • Status changed from new to assigned

Per discussion in Slack, I'm going to try to refresh this patch for 6.3.

Note: See TracTickets for help on using tickets.