image_send_to_editor

Filters the image HTML markup to send to the editor when inserting an image.

Description

apply_filters( 'image_send_to_editor', (string) $html, (int) $id, (string) $caption, (string) $title, (string) $align, (string) $url, (string|array) $size, (string) $alt ); 

Parameters (8)

0. $html (string)
The image HTML markup to send.
1. $id (int)
The attachment id.
2. $caption (string)
The image caption.
3. $title (string)
The image title.
4. $align (string)
The image alignment.
5. $url (string)
The image source URL.
6. $size (string|array)
Size of image. Image size or array of width and height values (in that order). Default medium..
7. $alt (string)
The image alternative, or alt, text.

Usage

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

Defined (2)

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

/wp-admin/includes/media.php  
  1. $html = apply_filters( 'image_send_to_editor', $html, $id, $caption, $title, $align, $url, $size, $alt ); 
/wp-includes/default-filters.php  
  1. add_filter( 'image_send_to_editor', 'image_add_caption', 20, 8 );