get_background_image example

<?php         if ( $this->admin_image_div_callback ) {
            call_user_func( $this->admin_image_div_callback );
        } else {
            $background_styles = '';
            $bgcolor           = get_background_color();
            if ( $bgcolor ) {
                $background_styles .= 'background-color: #' . $bgcolor . ';';
            }

            $background_image_thumb = get_background_image();
            if ( $background_image_thumb ) {
                $background_image_thumb = esc_url( set_url_scheme( get_theme_mod( 'background_image_thumb', str_replace( '%', '%%', $background_image_thumb ) ) ) );
                $background_position_x  = get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) );
                $background_position_y  = get_theme_mod( 'background_position_y', get_theme_support( 'custom-background', 'default-position-y' ) );
                $background_size        = get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size' ) );
                $background_repeat      = get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) );
                $background_attachment  = get_theme_mod( 'background_attachment', get_theme_support( 'custom-background', 'default-attachment' ) );

                // Background-image URL must be single quote, see below.                 $background_styles .= " background-image: url('$background_image_thumb');"
                . " background-size: $background_size;"
                .
$media_states[] = __( 'Current Header Video' );
            }
        }
    }

    if ( current_theme_supports( 'custom-background' ) ) {
        $meta_background = get_post_meta( $post->ID, '_wp_attachment_is_custom_background', true );

        if ( ! empty( $meta_background ) && $meta_background === $stylesheet ) {
            $media_states[] = __( 'Background Image' );

            $background_image = get_background_image();
            if ( $background_image && wp_get_attachment_url( $post->ID ) === $background_image ) {
                $media_states[] = __( 'Current Background Image' );
            }
        }
    }

    if ( (int) get_option( 'site_icon' ) === $post->ID ) {
        $media_states[] = __( 'Site Icon' );
    }

    if ( (int) get_theme_mod( 'custom_logo' ) === $post->ID ) {
        
if ( is_user_logged_in() ) {
        $classes[] = 'logged-in';
    }

    if ( is_admin_bar_showing() ) {
        $classes[] = 'admin-bar';
        $classes[] = 'no-customize-support';
    }

    if ( current_theme_supports( 'custom-background' )
        && ( get_background_color() !== get_theme_support( 'custom-background', 'default-color' ) || get_background_image() ) ) {
        $classes[] = 'custom-background';
    }

    if ( has_custom_logo() ) {
        $classes[] = 'wp-custom-logo';
    }

    if ( current_theme_supports( 'responsive-embeds' ) ) {
        $classes[] = 'wp-embed-responsive';
    }

    

function get_background_image() {
    return get_theme_mod( 'background_image', get_theme_support( 'custom-background', 'default-image' ) );
}

/** * Displays background image path. * * @since 3.0.0 */
function background_image() {
    echo get_background_image();
}

/** * Retrieves value for custom background color. * * @since 3.0.0 * * @return string */
function get_background_color() {
    return get_theme_mod( 'background_color', get_theme_support( 'custom-background', 'default-color' ) );
}
Home | Imprint | This part of the site doesn't use cookies.