On this page
image_media_send_to_editor( string $html, int $attachment_id, array $attachment ): string
Retrieves the media element HTML to send to the editor.
Parameters
$htmlstring Required$attachment_idint Required$attachmentarray Required
Return
string
Source
File: wp-admin/includes/media.php. View all references
function image_media_send_to_editor( $html, $attachment_id, $attachment ) {
$post = get_post( $attachment_id );
if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) {
$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' ) || get_attachment_link( $attachment_id ) === $url );
return get_image_send_to_editor( $attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt );
}
return $html;
}
Related
Uses
| Uses | Description |
|---|---|
| get_image_send_to_editor() wp-admin/includes/media.php | Retrieves the image HTML to send to the editor. |
| get_attachment_link() wp-includes/link-template.php | Retrieves the permalink for an attachment. |
| get_post() wp-includes/post.php | Retrieves post data given a post ID or post object. |
Changelog
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/image_media_send_to_editor