Themes: Add ability to show a random header image
|Reported by:||lancewillett||Owned by:||ryan|
Add the option to load a different header image with each page load.
(Note: this is not intended to be a "random image rotator" that changes the image without a page load.)
If a theme has multiple headers defined with register_default_headers(), and the theme chooses to enable this feature, show a new option in checkbox in Appearance > Header that turns on the randomization.
Make the new option the first (or last) radio option in the form so that you choose not to use a single image, but to show any of them on any page or post. See attached screenshot "random-option-admin-example.png" for a visual example.
- Themes wishing to use this feature should define multiple header images with register_default_headers().
- Then turn it on with define( 'HEADER_IMAGE', 'random' ) to set it on by default for the theme. If set to "random" and a user visits Appearance > Header the "Show Random Image" option should be selected instead of one of the images.
When get_header_image() is called from a template, instead of returning the value in "header_image" theme_mod, the function should pick a random node from the global $_wp_default_headers variable and return its URL instead.
Change History (43)
6 years ago
- Cc lance@… added
- Keywords has-patch dev-feedback added; needs-patch removed