image_media_send_to_editor

Retrieves the media element HTML to send to the editor.

Description

(string) image_media_send_to_editor( (string) $html, (integer) $attachment_id, (array) $attachment ); 

Returns (string)

Parameters (3)

0. $html (string)
The html.
1. $attachment_id (integer)
The attachment id.
2. $attachment (array)
The attachment.

Usage

  1. if ( !function_exists( 'image_media_send_to_editor' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/media.php'; 
  3.  
  4. // The html. 
  5. $html = ''; 
  6.  
  7. // The attachment id. 
  8. $attachment_id = null; 
  9.  
  10. // The attachment. 
  11. $attachment = array(); 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = image_media_send_to_editor($html, $attachment_id, $attachment); 
  15.  

Defined (1)

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

/wp-admin/includes/media.php  
  1. function image_media_send_to_editor($html, $attachment_id, $attachment) { 
  2. $post = get_post($attachment_id); 
  3. if ( substr($post->post_mime_type, 0, 5) == 'image' ) { 
  4. $url = $attachment['url']; 
  5. $align = !empty($attachment['align']) ? $attachment['align'] : 'none'; 
  6. $size = !empty($attachment['image-size']) ? $attachment['image-size'] : 'medium'; 
  7. $alt = !empty($attachment['image_alt']) ? $attachment['image_alt'] : ''; 
  8. $rel = ( strpos( $url, 'attachment_id') || $url === get_attachment_link( $attachment_id ) ); 
  9.  
  10. return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt); 
  11.  
  12. return $html;