Exposes an image through the WordPress REST API.
Description
This is used for fetching this information when user has no rights to update settings.
Parameters
$response
WP_REST_Responserequired- REST API response.
$image_id
intrequired- Image attachment ID.
$type
stringrequired- Type of Image.
Source
protected function add_image_to_index( WP_REST_Response $response, $image_id, $type ) {
$response->data[ $type ] = (int) $image_id;
if ( $image_id ) {
$response->add_link(
'https://api.w.org/featuredmedia',
rest_url( rest_get_route_for_post( $image_id ) ),
array(
'embeddable' => true,
'type' => $type,
)
);
}
}
Changelog
Version | Description |
---|---|
5.9.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.