wp_ajax_cropped_attachment_id

Filters the attachment ID for a cropped image.

Description

apply_filters( 'wp_ajax_cropped_attachment_id', (int) $attachment_id, (string) $context ); 

Parameters (2)

0. $attachment_id (int)
The attachment ID of the cropped image.
1. $context (string)
The Customizer control requesting the cropped image.

Usage

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

Defined (1)

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

/wp-admin/includes/ajax-actions.php  
  1. $attachment_id = apply_filters( 'wp_ajax_cropped_attachment_id', $attachment_id, $context );