On this page
get_header_image(): string|false
Retrieves header image for custom header.
Return
string|false
Source
File: wp-includes/theme.php. View all references
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();
}
/**
* Filters the header image URL.
*
* @since 6.1.0
*
* @param string $url Header image URL.
*/
$url = apply_filters( 'get_header_image', $url );
if ( ! is_string( $url ) ) {
return false;
}
$url = trim( $url );
return sanitize_url( set_url_scheme( $url ) );
}
Hooks
- apply_filters( 'get_header_image',
string $url ) -
Filters the header image URL.
Related
Uses
| Uses | Description |
|---|---|
| get_theme_support() wp-includes/theme.php | Gets the theme support arguments passed when registering that support. |
| is_random_header_image() wp-includes/theme.php | Checks if random header image is in use. |
| get_random_header_image() wp-includes/theme.php | Gets random header image URL from registered images in theme. |
| get_theme_mod() wp-includes/theme.php | Retrieves theme modification value for the active theme. |
| sanitize_url() wp-includes/formatting.php | Sanitizes a URL for database or redirect usage. |
| set_url_scheme() wp-includes/link-template.php | Sets the scheme for a URL. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| get_media_states() wp-admin/includes/template.php | Retrieves an array of media states from an attachment. |
| get_header_video_settings() wp-includes/theme.php | Retrieves header video settings. |
| get_header_image_tag() wp-includes/theme.php | Creates image tag markup for a custom header image. |
| has_header_image() wp-includes/theme.php | Checks whether a header image is set or not. |
| Custom_Image_Header::step_1() wp-admin/includes/class-custom-image-header.php | Display first step of custom header image page. |
| _delete_attachment_theme_mod() wp-includes/theme.php | Checks an attachment being deleted to see if it’s a header or background image. |
| header_image() wp-includes/theme.php | Displays header image URL. |
Changelog
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_header_image