[wp-trac] [WordPress Trac] #46128: Custom header "Hide image" button not displayed when randomizing images via theme setup
WordPress Trac
noreply at wordpress.org
Mon Jan 28 16:10:40 UTC 2019
#46128: Custom header "Hide image" button not displayed when randomizing images via
theme setup
--------------------------+-----------------------------
Reporter: webmandesign | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Customize | Version: 5.0.3
Severity: normal | Keywords:
Focuses: ui |
--------------------------+-----------------------------
**DESCRIPTION**
When registering multiple [https://codex.wordpress.org/Custom_Headers
custom header] images via theme code, and setting them to randomize (by
enabling `random-default` custom header attribute), there is no "**Hide
image**" button displayed. But the image should be displayed even in this
case.
The only way to enable "**Hide image**" button is to set `default-image`
attribute during custom header registration in the theme code. But this
actually effectively disables images randomization...
----
**HOW TO TEST/REPRODUCE**
Append this code to Twenty Nineteen theme's `functions.php` file (without
opening `<?php`) to test - see the code comments for more details:
{{{#!php
<?php
function test_custom_header_hide_button() {
/**
* Registering custom header support.
*
* The issue description:
* ======================
* When 'default-image' is set, there is "Hide image" button
* displayed in "Header Image" section of customizer. But now
* the 'random-default' does not work.
* On the other side, if 'default-image' is not set, "Hide image"
* button is not displayed in "Header Image" section of customizer
* when we have 'random-default' enabled.
* In both cases the "Hide image" button should be available.
*
* How to test:
* ============
* Simply (un)comment the 'default-image' to see the difference
* in "Header Image" section of customizer.
* But do not save/publish your customizer as we are testing
* how the theme code is treated in customizer!
*/
add_theme_support( 'custom-header', array(
// 'default-image' =>
'https://via.placeholder.com/1000x200/000099/ffffff?text=Image+default',
'random-default' => true,
// Irrelevant, but required options:
'height' => 200,
'width' => 1000,
) );
// Registering some images to randomize from:
register_default_headers( array(
'image-1' => array(
'url' =>
'https://via.placeholder.com/1000x200/990000/ffffff?text=Image+1',
'thumbnail_url' =>
'https://via.placeholder.com/250x50/990000/ffffff?text=Image+1',
'description' => 'Image 1',
),
'image-2' => array(
'url' =>
'https://via.placeholder.com/1000x200/009900/ffffff?text=Image+2',
'thumbnail_url' =>
'https://via.placeholder.com/250x50/009900/ffffff?text=Image+2',
'description' => 'Image 2',
),
) );
}
add_action( 'after_setup_theme', 'test_custom_header_hide_button' );
// Display the custom header in theme footer for preview:
add_action( 'wp_footer', 'the_custom_header_markup' );
}}}
----
**SCREENSHOT**
[[Image(custom-header-setup-via-theme.png)]]
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46128>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list