WordPress函数get_header_image()

描述:

检索自定义页眉的页眉图片

用法:

<?php get_header_image(); ?>

返回值:

(string)

返回页眉图片路径。

如果值为空将返回:

  • 当前主题不支持头部图片
  • 当前主题不支持头部图片。但是,用户已经从外观->头部图像中选择了“删除头部图像”选项。

示例:

<img src="<?php echo( get_header_image() ); ?>" alt="<?php echo( get_bloginfo( 'title' ) ); ?>" />

源文件:

/**
 * Retrieve header image for custom header.
 *
 * @since 2.1.0
 *
 * @return string|false
 */
function get_header_image() {
	$url = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) );

	if ( 'remove-header' == $url )
		return false;

	if ( is_random_header_image() )
		$url = get_random_header_image();

	return esc_url_raw( set_url_scheme( $url ) );
}