media_send_to_editor()
概述
media_send_to_editor() 是一个 WordPress 函数,用于将图像 HTML 代码插入到编辑器中。它接受一个必需的字符串参数 $html,并返回处理后的 HTML 内容。
关键要点
- 函数名:media_send_to_editor()
- 主要功能:向编辑器添加图像 HTML
- 参数:$html(字符串,必需)
- 引入版本:WordPress 2.5.0
- 相关函数:被 media_upload_form_handler() 和 wp_media_upload_handler() 使用
Adds image HTML to editor.
Parameters
$htmlstringrequired
Source
function media_send_to_editor( $html ) {
?>
<script type="text/javascript"></script>
</pre><p class="wporg-dot-link-list"><a href="https://developer.wordpress.org/reference/files/wp-admin/includes/media.php/">View all references</a> <a href="https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/media.php#L273">View on Trac</a> <a href="https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/media.php#L273-L281">View on GitHub</a></p></section>
<section class="wp-block-wporg-code-reference-related" data-nosnippet="true"><h2 id="related" class="is-toc-heading wp-block-heading has-heading-5-font-size" tabindex="-1" ><a href="#related">Related</a></h2> <section style="margin-top:var(--wp--preset--spacing--20)" class="wp-block-wporg-code-table" id="uses"><figure class="wp-block-table "><table><thead><tr><th scope="col">Uses</th><th scope="col">Description</th></tr></thead><tbody><tr class=""><td><a href="https://developer.wordpress.org/reference/functions/wp_json_encode/">wp_json_encode()</a><code>wp-includes/functions.php
Encodes a variable into JSON, with some confidence checks.
| Used by | Description |
|---|---|
media_upload_form_handler()wp-admin/includes/media.php |
Handles form submissions for the legacy media uploader. |
wp_media_upload_handler()wp-admin/includes/media.php |
Handles the process of uploading media. |
Changelog
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |