header_image()
云策文档标注
概述
header_image() 是一个 WordPress 函数,用于输出自定义标题图像的 URL。它通过调用 get_header_image() 获取图像 URL,并使用 esc_url() 进行安全转义后直接输出。
关键要点
- 函数功能:输出自定义标题图像的 URL,如果存在则显示,否则无输出。
- 内部实现:基于 get_header_image() 获取图像 URL,并使用 esc_url() 进行 URL 清理和转义以确保安全性。
- 相关函数:get_header_image() 用于检索图像 URL,esc_url() 用于 URL 验证和清理。
- 版本历史:自 WordPress 2.1.0 版本引入。
代码示例
function header_image() {
$image = get_header_image();
if ( $image ) {
echo esc_url( $image );
}
}
原文内容
Displays header image URL.
Source
function header_image() {
$image = get_header_image();
if ( $image ) {
echo esc_url( $image );
}
}
Changelog
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |
Skip to note 2 content
Anthony Hortin
Related:
has_header_image
get_header_image