WP_REST_Server::add_image_to_index() – Exposes an image through the WordPress REST API.
You appear to be a bot. Output may be restricted
Description
Exposes an image through the WordPress REST API.
This is used for fetching this information when user has no rights to update settings.
Usage
WP_REST_Server::add_image_to_index( $response, $image_id, $type );
Parameters
- $response
- ( WP_REST_Response ) required – REST API response.
- $image_id
- ( int ) required – Image attachment ID.
- $type
- ( string ) required – Type of Image.
Returns
void
Source
File name: wordpress/wp-includes/rest-api/class-wp-rest-server.php
Lines:
1 to 13 of 13
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, ) ); } }