检索要发送到编辑器的媒体元素HTML。

原型

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

参数

$html (string) (Required)

$attachment_id (integer) (Required)

$attachment (array) (Required)

返回值

(string)  

源文件

路径:wp-admin/includes/media.php

<?php
...
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;
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/image_media_send_to_editor/