rest_api_thumbnail_sizes

Filter the thumbnail sizes available for each attachment ID.

Description

apply_filters( 'rest_api_thumbnail_sizes', (array) $metadata_sizes, (string) $media_id ); 

Parameters (2)

0. $metadata_sizes (array)
Array of thumbnail sizes available for a given attachment ID.
1. $media_id (string)
Attachment ID.

Usage

To run the hook, copy the example below.
  1. $metadata_sizes = apply_filters( 'rest_api_thumbnail_sizes', $metadata_sizes, $media_id ); 
  2.  
  3. if ( !empty( $metadata_sizes ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the rest_api_thumbnail_sizes callback 
  2. function filter_rest_api_thumbnail_sizes( $metadata_sizes, $media_id ) { 
  3. // make filter magic happen here... 
  4. return $metadata_sizes
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'rest_api_thumbnail_sizes', 'filter_rest_api_thumbnail_sizes', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'rest_api_thumbnail_sizes', 'filter_rest_api_thumbnail_sizes', 10, 2 ); 

Defined (2)

The filter is defined in the following location(s).

/class.json-api-endpoints.php  
  1. $sizes = apply_filters( 'rest_api_thumbnail_sizes', $metadata['sizes'], $media_id ); 
/sal/class.json-api-post-base.php  
  1. $sizes = apply_filters( 'rest_api_thumbnail_sizes', $metadata['sizes'], $media_id );