get_background_image()

最后更新于:2021-11-26 05:32:07

get_background_image()

Retrieves background image for custom background.

响应

(string)

源文件

文件: gc-includes/theme.php

function get_background_image() {
	return get_theme_mod( 'background_image', get_theme_support( 'custom-background', 'default-image' ) );
}
// Declare $post global if used outside of the loop.
$post = get_post();

// check to see if the theme supports Featured Images, and one is set
if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) ) {
        
    // Specify desired image size in place of 'full'.
    $page_bg_image     = gc_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
    $page_bg_image_url = $page_bg_image[0]; // This returns just the URL of the image.

} else {
    // The fallback – our current active theme's default bg image.
    $page_bg_image_url = get_background_image();
}

// And below, spit out the <style> tag... ?>
<style type="text/css" id="custom-background-css-override">
    body.custom-background { background-image: url('<?php echo $page_bg_image_url; ?>'); }
</style>