get_header_image

The timeline below displays how wordpress function get_header_image has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Retrieves 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();
    }
    /**
     * 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));
}

WordPress Version: 5.5

/**
 * Retrieves 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));
}

WordPress Version: 4.2

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

WordPress Version: 3.7

/**
 * Retrieve header image for custom header.
 *
 * @since 2.1.0
 *
 * @return string
 */
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));
}