Add featured +- attached images to post endpoint in REST API

When one pulls up the endpoint “wp-json/wp/v2/posts” we get a key called “featured_media” but it returns an integer value.

Can’t we rewrite this to give a proper URL to the featured image? or even add another key that has attached images as URLs.

This will prevent the extra queries one has to return the image URLs or even install bloated plugins to get this information.

I know the endpoint already has so much information one rarely needs thus the growth of tech like GraphQL but we could also consider Author name & description to the individual posts.

This is voice is for decoupling ClassicPress to modern apps or front-ends.


Read-only archive: Issues · ClassicPress/ClassicPress · GitHub

Author: Laurence Bahiirwa

Vote count: 5

Status: open

Tags:

  • difficulty-hard
  • request-add-feature

Comments

@james @omukiguy you two were discussing this petition back in 2018. Has anything changed since then?

I still hold the view that instead of serving media IDs only, we could serve the image URLs like we do for post content, title etc. It is the one inconsistency currently on the API for me.

Pros

  • Data URL for images straight off the bat.
  • Removes extra use of plugins to make custom endpoints for data in the post.

Cons

If this is a stretch, James shares a backport we need to do for the improvement.

1 Like

Are you able to do the backport to complete this petition?
https://core.trac.wordpress.org/ticket/39696

1 Like

This can be followed here WP-r47224: Introduce selective link embedding via REST API by bahiirwa · Pull Request #1024 · ClassicPress/ClassicPress · GitHub

1 Like

This will be included in the re-fork. The petition will be closed.