image_media_send_to_editor() - WordPress 函数参考中文文档

返回介绍

image_media_send_to_editor()

发布于 2017-09-11 字数1871 浏览 817 评论 0

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

Retrieves the media element HTML to send to the editor.


描述


参数

$html

(string)
(Required)

$attachment_id

(integer)
(Required)

$attachment

(array)
(Required)


返回值

(string)


源代码

File: wp-admin/includes/media.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;
}

更新日志

Version 描述
2.5.0 Introduced.

相关函数

Uses

  • wp-admin/includes/media.php:
    get_image_send_to_editor()
  • wp-includes/link-template.php:
    get_attachment_link()
  • wp-includes/post.php:
    get_post()

User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!