Opened 4 years ago
Closed 4 years ago
#53676 closed defect (bug) (invalid)
Default Custom Header image is not staying active
Reported by: | Andre Jutras | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 5.7.2 |
Component: | Themes | Keywords: | |
Focuses: | Cc: |
Description
I remember this once long ago but cannot remember the issue. Working on a theme and noticed that when there are no additional images uploaded to the Header Image via the customizer, and when "hiding" the default header image, then reselecting the default one, click Save and then refresh, it does not stay active. I tried this by adding the header support in the Twenty Twenty One theme, nope, doesn't work there either.
I tried this in WP 5.7.2 and also 5.8 RC3
Test Code to add support to the 2021 theme function file:
// Setup the WordPress core custom header image. add_theme_support( 'custom-header', array( 'width' => 1920, 'height' => 800, 'flex-height' => true, 'flex-width' => true, 'default-image' => get_template_directory_uri() . '/assets/images/header.jpg', 'uploads' => true, ) );
Then, to add it to the header.php template:
<?php if ( get_header_image() ) : ?> <img src="<?php header_image(); ?>"> <?php endif; ?>
Head over to the customizer's Header Image tab and make sure no added images exist, except the default one.
- Make sure the default header is not active
- Select the default (suggested) header and save
- Refresh the full customizer window
- The default image shows as a thumbnail but is no longer active and is now Suggested.
Even if I upload additional images, try them out, they work, however, if I once again select the default header image, it's a no-go on it.
I think I found the issue...default custom header image(s) need to have them registered, in addition to
So far, it seems to have solved it.