Theme Customizer Custom Background / Header Image

Here’s some code I use which places a control in the Title’s and Taglines section to add a logo image..

$wp_customize->add_setting( 'theme_logo' );
$wp_customize->add_control( 
    new WP_Customize_Image_Control(
        $wp_customize,'theme_logo',array(
            'label' => 'Logo',
            'section' => 'title_tagline',
            'settings' => 'theme_logo',
            'priority' => 1
        )
    )
);

I then call it in header.php with this bit..

<?php if( get_theme_mod( 'theme_logo' ) != '') { ?> // if there is a logo img
    <img src="https://wordpress.stackexchange.com/questions/123892/<?php echo get_theme_mod("tonic_logo'); ?>">
<?php } ?>

For a background image you can use the exact same thing as the logo..

$wp_customize->add_setting( 'theme_header_bg' );
$wp_customize->add_control( 
    new WP_Customize_Image_Control(
        $wp_customize,'theme_header_bg',array(
            'label' => 'Header Background Image',
            'section' => 'title_tagline',
            'settings' => 'theme_header_bg',
            'priority' => 2
        )
    )
);

We’ve got the control all set up, in an identical fashion as the other image (the logo). Now to header.php we just call it slightly different so it appears as a background rather than an img..

<?php 
    if( get_theme_mod( 'theme_header_bg' ) != '') { // if there is a background img
        $theme_header_bg = get_theme_mod('theme_header_bg'); // Assigning it to a variable to keep the markup clean
    }
?>

<header style="background-image:url('<?php echo $theme_header_bg ?>');">