[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 19 13:13:15 UTC 2026


#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:  3.4
 Severity:  normal                     |  Resolution:
 Keywords:  has-patch has-screenshots  |     Focuses:
---------------------------------------+------------------------------
Changes (by ozgursar):

 * keywords:  has-patch needs-testing => has-patch has-screenshots


Comment:

 == Test Report
 === Description
 This report validates whether the indicated patch works as expected.

 Patch tested:
 https://core.trac.wordpress.org/attachment/ticket/46128/46128.diff

 === Environment
 - WordPress: 7.0-alpha-61215-src
 - PHP: 8.2.29
 - Server: nginx/1.29.4
 - Database: mysqli (Server: 8.4.7 / Client: mysqlnd 8.2.29)
 - Browser: Chrome 143.0.0.0
 - OS: macOS
 - Theme: Twenty Nineteen 3.2
 - MU Plugins: None activated
 - Plugins:
   * Test Reports 1.2.1

 === Steps to Reproduce
 1. Activate Twenty Nineteen theme
 2. Add the following code to functions.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://i.imgur.com/ErERGJz.jpeg',
                 'random-default' => true,

                 // Irrelevant, but required options:
                 'height' => 450,
                 'width'  => 1000,
         ) );

         // Registering some images to randomize from:
         register_default_headers( array(
                 'image-1' => array(
                         'url'           =>
 'https://i.imgur.com/pdH4R4c.jpeg',
                         'thumbnail_url' =>
 'https://i.imgur.com/pP6RGgu.jpeg',
                         'description'   => 'Image 1',
                 ),
                 'image-2' => array(
                         'url'           =>
 'https://i.imgur.com/2ZSMKRP.jpeg',
                         'thumbnail_url' =>
 'https://i.imgur.com/YoEVLuS.jpeg',
                         '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' );
 }}}

 3. View Appearance > Customize > Header Image
 4. When default image is commented out Hide Image button is not visible
 5. Go back to functions.php and remove comment before line

 {{{
 //'default-image' => 'https://i.imgur.com/ErERGJz.jpeg',
 }}}

 6. View Appearance > Customize > Header Image again
 7. When default image is not commented out Hide Image button is visible


 === Actual Results
 1. ✅ Issue resolved with patch.
 2. Hide Image button is visible when default image is commented out.

 === Supplemental Artifacts
 Before applying patch:

 With default image:
 [[Image(https://i.imgur.com/ggAgdKG.png)]]

 Without default image:
 [[Image(https://i.imgur.com/N2cQHDA.png)]]

 ----
 After applying patch:

 With default image:
 [[Image(https://i.imgur.com/sIXyapH.png)]]

 Without default image:
 [[Image(https://i.imgur.com/ik1BCl0.png)]]

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46128#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list