返回介绍

get_header_image()

发布于 2017-09-10 23:22:35 字数 2716 浏览 1088 评论 0 收藏 0

get_header_image()

Retrieve header image for custom header.


description


返回值

(string|false)


源代码

File: wp-includes/theme.php

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 ) );
}

更新日志

Versiondescription
2.1.0Introduced.

相关函数

Uses

  • wp-includes/theme.php: get_theme_support()
  • wp-includes/theme.php: is_random_header_image()
  • wp-includes/theme.php: get_random_header_image()
  • wp-includes/theme.php: get_theme_mod()
  • wp-includes/formatting.php: esc_url_raw()
  • wp-includes/link-template.php: set_url_scheme()
  • Show 1 more use Hide more uses

Used By

  • wp-includes/theme.php: get_header_video_settings()
  • wp-includes/theme.php: get_header_image_tag()
  • wp-includes/theme.php: has_header_image()
  • wp-admin/includes/template.php: _media_states()
  • wp-admin/custom-header.php: Custom_Image_Header::step_1()
  • wp-includes/theme.php: _delete_attachment_theme_mod()
  • wp-includes/theme.php: header_image()
  • Show 2 more used by Hide more used by

User Contributed Notes

  1. Skip to note content You must log in to vote on the helpfulness of this noteVote results for this note: 3You must log in to vote on the helpfulness of this note Contributed by jessedyck

    Before using this, check out get_header_image_tag() first. That’s a new function in 4.4 that’ll return an tag including the srcset attributes for responsive images.

    https://developer.wordpress.org/reference/functions/get_header_image_tag/

  2. Example

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文