Clarification: My default header image will not RE-display (by clicking suggested image) after it has been removed using theme customizer “Hide Image” option.
-
I added theme support for Custom Header Image
// Add Theme Support for Custom Header Image add_theme_support( 'custom-header', array( 'default-image' => get_template_directory_uri() . '/assets/img/hdr_earth.jpg', 'default-text-color' => '#e2f0d6', 'header-text' => true, 'uploads' => true, 'width' => 1140, 'height' => 200, 'wp-head-callback' => 'wpfw_style_header', ) );
-
Inside the Theme Customizer I see the (default) image displayed as:
- The “Current Header” box, and
- In the “Suggested” box
-
I deleted the current header image by clicking the “Hide Image” button.
And this is where the problem started
When I attempt to re-add the default image by clicking on the “Suggested” (i.e. default) image…
- The image is displayed in the customizer window.
- But the image will not save, so the image does not display on the web page.
A var_dump( get_header_image() );
returned false
, so after reading the function in the core, I see this if ( 'remove-header' == $url ) return false;
.
So a var_dump( get_theme_mods() )
does indeed show 'header_image' => string 'remove-header' (length=13)
.
???
… now this is after I added the default image back and saved.
What am I missing?
The entire script (custom-header.php)
if ( ! function_exists( 'wpfw_custom_header' ) ) {
function wpfw_custom_header() {
// Add theme Support for Custom Backgrounds
add_theme_support( 'custom-background',
array(
'default-color' => '#e2f0d6',
'default-image' => get_template_directory_uri() . '/assets/img/bgp-128x180.jpg',
)
);
// Add Theme Support for Custom Header Image
add_theme_support( 'custom-header',
array(
'default-image' => get_template_directory_uri() . '/assets/img/hdr_earth.jpg',
'default-text-color' => '#e2f0d6',
'header-text' => true,
'uploads' => true,
'width' => 1140,
'height' => 200,
'wp-head-callback' => 'wpfw_style_header',
)
);
} // end wpfw_custom_header()
} // end if
// Hook into the 'after_setup_theme' action
add_action( 'after_setup_theme', 'wpfw_custom_header', 11 );
/**
* ----------------------------------------------
* Callback function for updating header styles
* ----------------------------------------------
*/
if ( ! function_exists( 'wpfw_style_header' ) ) {
function wpfw_style_header() {
$text_color = get_header_textcolor();
?>
<style type="text/css" id="wpfw-custom-header-styles">
.site-title a.site-title-link {
color: #<?php echo esc_attr( $text_color ); ?>;
}
<?php if ( display_header_text() != true ) : ?>
.site-title {
display: none;
}
<?php endif; ?>
</style>
<?php
} // end wpfw_style_header()
} // end if...