image_add_caption_text
云策文档标注
概述
image_add_caption_text 是一个 WordPress 过滤器,用于修改图片的标题文本。如果标题文本为空,则不会在编辑器中为图片添加标题短代码。
关键要点
- 过滤器名称:image_add_caption_text,用于过滤图片的标题文本。
- 参数:$caption(原始标题文本,字符串类型)和 $id(附件 ID,整数类型)。
- 注意事项:如果标题文本为空,将不会添加标题短代码,并跳过 image_add_caption_shortcode 过滤器。
- 相关函数:image_add_caption(),用于向编辑器添加带标题的图片短代码。
- 版本历史:从 WordPress 4.1.0 版本引入。
代码示例
$caption = apply_filters( 'image_add_caption_text', $caption, $id );
原文内容
Filters the caption text.
Description
Note: If the caption text is empty, the caption shortcode will not be appended to the image HTML when inserted into the editor.
Passing an empty value also prevents the ‘image_add_caption_shortcode’ Filters from being evaluated at the end of image_add_caption() .
Parameters
$captionstring-
The original caption text.
$idint-
The attachment ID.
Source
$caption = apply_filters( 'image_add_caption_text', $caption, $id );
Changelog
| Version | Description |
|---|---|
| 4.1.0 | Introduced. |