media_send_to_editor
云策文档标注
概述
media_send_to_editor 是一个 WordPress 过滤器,用于修改发送到编辑器的媒体项的 HTML 标记。它允许开发者在媒体项插入编辑器时自定义其输出格式。
关键要点
- 这是一个过滤器钩子,用于处理媒体项发送到编辑器时的 HTML 标记。
- 接收三个参数:$html(HTML 标记字符串)、$send_id($_POST['send'] 的第一个键)和 $attachment(附件元数据数组)。
- 在 WordPress 2.5.0 版本中引入,常用于自定义媒体插入行为。
注意事项
- 使用时需确保正确处理参数,避免破坏默认的媒体插入功能。
- 可结合 wp_get_attachment_metadata() 等函数获取更多附件信息。
原文内容
Filters the HTML markup for a media item sent to the editor.
Description
See also
Parameters
$htmlstring-
HTML markup for a media item sent to the editor.
$send_idint-
The first key from the $_POST[
'send'] data. $attachmentarray-
Array of attachment metadata.
Source
$html = apply_filters( 'media_send_to_editor', $html, $send_id, $attachment );
Changelog
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |