Skip to content
This repository has been archived by the owner. It is now read-only.

Featured image is not in _links on post response #1476

Closed
joehoyle opened this issue Aug 12, 2015 · 10 comments

Comments

@joehoyle
Copy link
Contributor

commented Aug 12, 2015

We should link to the featured image, so it can be embedded, see http://demo.wp-api.org/wp-json/wp/v2/posts/111?_embed it's not included in the links.

@rmccue I know we ran into an issue with it embedding all attachments attached to the post, maybe that's the issue here.

@joehoyle joehoyle added this to the 2.0 milestone Aug 12, 2015

@joehoyle

This comment has been minimized.

Copy link
Contributor Author

commented Aug 12, 2015

Oh, I see we are linked to attachment though it's not clear if that is meant to be for all attachments, or the featured image. Currently it's all attachments

@rhurling

This comment has been minimized.

Copy link

commented Aug 12, 2015

The featured image is not necessarily an attachment of the current page though. (At least I think it isn't)

@rmccue

This comment has been minimized.

Copy link
Member

commented Aug 14, 2015

I don't know when this changed, but yeah, it does cause problems right now. We're running into problems on a client site with this, since the featured images don't have the post as a parent.

We should change to having a direct link to the featured image at /media/{featured_image} with embedded: true, and a link to /media?post={id} without embeddability. The latter isn't something you'd need embedded most of the time, whereas the featured image itself is.

@rmccue rmccue added the Bug label Aug 14, 2015

@rmccue

This comment has been minimized.

Copy link
Member

commented Sep 8, 2015

While we're at it, let's change so nav_menu_item and revision aren't marked as embeddable. Following the 80/20 rule, most people aren't going to need those to render a post.

(Standard for picking embeddability should be "would I need this to render the item in a theme?")

@danielbachhuber

This comment has been minimized.

Copy link
Member

commented Oct 28, 2015

Some comments from @joehoyle in #1563 (comment)

Looking at the response in http://demo.wp-api.org/wp-json/wp/v2/posts/162?_embed, there's no way to hardcode the path to the featured image link for embedded item, you'd have to do a filter on the http://v2.wp-api.org/attachment relation to only get ones with embedded => true.

If you want to get the data from embedded, there's no way to programmatically know which embedded attachment is the featured image, short of cross referencing with the _links array, or blindly _embedded["http://v2.wp-api.org/attachment"][0]`.

I don't really understand the rational for the way we have it now, they are different relationships; it seems we are grouping the attachments with the featured image because they are the same resource type, which actually has little bearing on what the relationship is.

@colinhowells

This comment has been minimized.

Copy link

commented Oct 30, 2015

Having the featured image in its own dedicated path (inside or outside the 'attachments') would allow you to embed and access its sizes, as well. It would be great to easily grab featured_image/sizes/medium/url.

@rmccue rmccue self-assigned this Nov 2, 2015

@rmccue

This comment has been minimized.

Copy link
Member

commented Nov 2, 2015

Per @danielbachhuber and @joehoyle, let's keep the attachment relation, but add a featuredmedia relation (as it appears you can use audio or video for the featured image too). Duplicating shouldn't be a huge issue.

@rmccue

This comment has been minimized.

Copy link
Member

commented Nov 2, 2015

as it appears you can use audio or video for the featured image too

I misread the code here (it allows you to attach featured images for audio or video), but I think we should keep the name as featuredmedia. Given that it was originally "post thumbnails", then "featured image" in core, it could potentially allow a featured video in the future, so I'm thinking we look ahead.

@joehoyle

This comment has been minimized.

Copy link
Contributor Author

commented Nov 2, 2015

I'm +1 on that

@Cyberfolks

This comment has been minimized.

Copy link

commented Feb 26, 2018

array_name._embedded['wp:featuredmedia']['0'].source_url
try this for ionic

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
6 participants
You can’t perform that action at this time.