WordPress plugin intelligence profile

Better REST API Featured Images

Adds a top-level field with featured image data including available sizes and URLs to the post object returned by the REST API.

WP PlugIndex snapshot

Current directory snapshot

Tested up to WordPress 4.6
Current version1.2.1
WordPress coverageTested up to WordPress 4.6
Minimum stackWP 4.0 · PHP —
Directory statusactive
Last directory update30 Jul 201610y ago
Active installations2K+Adoption metric — not a quality score
WordPress.org rating5.0 / 5 from 11 ratings
Official packageDirect from WordPress.org

Repository metrics are context, not quality scores. Active installations measure adoption and can strongly reflect a plugin’s age and historical popularity. Ratings, recent updates and “Tested up to” metadata also do not guarantee modern code, error-free operation, security, feature completeness or suitability for a particular site. Why active installs don’t tell the whole story →

WP PlugIndex currently records Better REST API Featured Images version 1.2.1 as active, updated 10y ago and tested up to WordPress 4.6.

Overview

About this plugin

Note: You probably do not need this plugin. _embed to your URL and the response will then include all “embedded media”, including the featured image, and the data you get there is exactly what this plugin gives you. _embed.

_embed a try before using this plugin. 🙂

Version 2 of the WordPress REST API returns a featured_media field (formerly featured_image) on the post object by default, but this field is simply the image ID.

This plugin adds a better_featured_image field to the post object that contains the available image sizes and urls, allowing you to get this information without making a second request.

It takes this:

"featured_media": 13,

And turns it into this:

jpg" },

_embed. When no featured image has been set on the post the better_featured_image field will have a value of null.

I’ve done some basic performance tests that indicate the difference in response times with and without this plugin to be about 10-15ms for a collection of 10 posts and 0-5ms for a single post. For me this is much faster than making a second request to /media/, especially for multiple posts.

0, there is a filter better_rest_api_featured_image that allows you to add custom data to the better_featured_image field. The filter is directly on the return value of the function that returns the better_featured_image field. This can be used to do things like add custom image meta or an SVG version of the image to the response.

Here’s an example of how you might use it:

add_filter( 'better_rest_api_featured_image', 'xxx_modify_rest_api_featured_image', 10, 2 ); /** * Modify the Better REST API Featured Image response. * * @param array $featured_image The array of image data. * @param int $image_id The image ID.

* * @return array The modified image data. */ function xxx_modify_rest_api_featured_image( $featured_image, $image_id ) {

// Add an extra_data_string field with a string value. ';

// Add an extra_data_array field with an array value. ', );

return $featured_image; }

This plugin is on on Github and pull requests are always welcome. 🙂

WordPress.org metadata

Plugin tags

Topics listed for this plugin in the WordPress.org directory.

  • featured
  • images
  • post
  • rest
  • thumbnail
Compatibility & maintenance

Compatibility & maintenance

Tested up to WordPress 4.6

Not yet marked as tested with WordPress 7.1. WordPress.org currently lists Tested up to 4.6.

Current WordPress releaseWordPress 7.1
WordPress.org Tested up to4.6
Minimum requirementsWordPress 4.0 · PHP not listed
Update activity30 Jul 201610y ago

“Tested up to” is directory metadata supplied by the plugin author. WP PlugIndex does not turn an older declaration into a claim that the plugin is incompatible.

Changes recorded by WP PlugIndex

Recent tracked changes

No tracked version or compatibility changes have been recorded by WP PlugIndex yet.

Tracking & source

WP PlugIndex tracks public WordPress.org directory metadata and records selected version, compatibility and availability changes as they are detected.

Plugin watchlist

Watch this plugin

Sign in to your WP PlugIndex account or create a free account. Free accounts can watch up to 5 plugins and see what changed.

Watch limit

Watchlist limit reached

You have reached your current active watch limit.