get_header_image example

/** * Checks whether a header image is set or not. * * @since 4.2.0 * * @see get_header_image() * * @return bool Whether a header image is set or not. */
function has_header_image() {
    return (bool) get_header_image();
}

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

    
<?php if ( get_custom_header() || display_header_text() ) : ?> <tr> <th scope="row"><?php _e( 'Preview' ); ?></th> <td> <?php             if ( $this->admin_image_div_callback ) {
                call_user_func( $this->admin_image_div_callback );
            } else {
                $custom_header = get_custom_header();
                $header_image  = get_header_image();

                if ( $header_image ) {
                    $header_image_style = 'background-image:url(' . esc_url( $header_image ) . ');';
                } else {
                    $header_image_style = '';
                }

                if ( $custom_header->width ) {
                    $header_image_style .= 'max-width:' . $custom_header->width . 'px;';
                }
                if ( $custom_header->height ) {
                    
$meta_header = get_post_meta( $post->ID, '_wp_attachment_is_custom_header', true );

        if ( is_random_header_image() ) {
            if ( ! isset( $header_images ) ) {
                $header_images = wp_list_pluck( get_uploaded_header_images(), 'attachment_id' );
            }

            if ( $meta_header === $stylesheet && in_array( $post->ID, $header_images, true ) ) {
                $media_states[] = __( 'Header Image' );
            }
        } else {
            $header_image = get_header_image();

            // Display "Header Image" if the image was ever used as a header image.             if ( ! empty( $meta_header ) && $meta_header === $stylesheet && wp_get_attachment_url( $post->ID ) !== $header_image ) {
                $media_states[] = __( 'Header Image' );
            }

            // Display "Current Header Image" if the image is currently the header image.             if ( $header_image && wp_get_attachment_url( $post->ID ) === $header_image ) {
                $media_states[] = __( 'Current Header Image' );
            }
        }

        
Home | Imprint | This part of the site doesn't use cookies.