wp_content_img_tag
云策文档标注
概述
wp_content_img_tag 是一个 WordPress 过滤器,用于在内容中过滤 img 标签,允许开发者根据上下文修改其属性或标记。
关键要点
- 过滤器名称:wp_content_img_tag
- 参数:$filtered_image(完整的 img 标签字符串)、$context(上下文信息,如过滤器名称或调用函数名)、$attachment_id(附件 ID,可能为 0 表示非附件图像)
- 用途:在 wp_filter_content_tags() 函数中调用,用于修改文章内容中的特定标签标记
- 引入版本:WordPress 6.0.0
代码示例
$filtered_image = apply_filters( 'wp_content_img_tag', $filtered_image, $context, $attachment_id );
原文内容
Filters an img tag within the content for a given context.
Parameters
$filtered_imagestring-
Full img tag with attributes that will replace the source img tag.
$contextstring-
Additional context, like the current filter name or the function name from where this was called.
$attachment_idint-
The image attachment ID. May be 0 in case the image is not an attachment.
Source
$filtered_image = apply_filters( 'wp_content_img_tag', $filtered_image, $context, $attachment_id );
Changelog
| Version | Description |
|---|---|
| 6.0.0 | Introduced. |