A WordPress-centric search engine for devs and theme authors



image_media_send_to_editor ›

Since2.5.0
Deprecatedn/a
image_media_send_to_editor ( $html, $attachment_id, $attachment )
Parameters: (3)
  • (string) $html
    Required: Yes
  • (integer) $attachment_id
    Required: Yes
  • (array) $attachment
    Required: Yes
Returns:
  • (string)
Defined at:
Codex:

Retrieves the media element HTML to send to the editor.



Source

function image_media_send_to_editor( $html, $attachment_id, $attachment ) {
	$post = get_post( $attachment_id );
	if ( substr( $post->post_mime_type, 0, 5 ) == 'image' ) {
		$url   = $attachment['url'];
		$align = ! empty( $attachment['align'] ) ? $attachment['align'] : 'none';
		$size  = ! empty( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium';
		$alt   = ! empty( $attachment['image_alt'] ) ? $attachment['image_alt'] : '';
		$rel   = ( strpos( $url, 'attachment_id' ) || $url === get_attachment_link( $attachment_id ) );

		return get_image_send_to_editor( $attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt );
	}

	return $html;
}