WP_REST_Server::add_image_to_index( WP_REST_Response $response, int $image_id, string $type )
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
-
(Required) REST API response.
- $image_id
-
(Required) Image attachment ID.
- $type
-
(Required) Type of Image.
Source
File: wp-includes/rest-api/class-wp-rest-server.php
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. |