get_attached_file
云策文档标注
概述
get_attached_file 是一个 WordPress 过滤器,用于基于附件 ID 过滤附件的文件路径。它允许开发者修改或检查附件文件的路径。
关键要点
- 这是一个过滤器 Hook,名称为 'get_attached_file'。
- 参数包括 $file(文件路径或 false)和 $attachment_id(附件 ID)。
- 用于在 get_attached_file() 函数中修改或验证附件文件路径。
代码示例
return apply_filters( 'get_attached_file', $file, $attachment_id );注意事项
- 此过滤器在 WordPress 2.1.0 版本中引入。
- 相关函数 get_attached_file() 位于 wp-includes/post.php 文件中。
原文内容
Filters the attached file based on the given ID.
Parameters
$filestring|false-
The file path to where the attached file should be, false otherwise.
$attachment_idint-
Attachment ID.
Source
return apply_filters( 'get_attached_file', $file, $attachment_id );
Changelog
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |