Opened 12 years ago
Closed 12 years ago
#22221 closed defect (bug) (fixed)
get_custom_header() does not handle a default registered header
Reported by: | nacin | Owned by: | nacin |
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Customize | Keywords: | has-patch |
Focuses: | Cc: |
Description
get_custom_header() handles two sources of data: the data of a random header image, and the saved header_image_data theme mod.
Before a theme is saved, header_image_data is not populated. If the theme has a default-image rather than a random-default, get_custom_header() will end up having no values for 'url' or 'thumbnail_url'.
Attached patch fixes that. Ideally, some logic in custom-header.php, this new logic, and the logic in _get_random_header_data() should come together in a much nicer way.
Attachments (2)
Change History (11)
#2
@
12 years ago
- Owner set to nacin
- Resolution set to fixed
- Status changed from new to closed
In 22436:
#3
@
12 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
I'm using a default header, yet $_wp_default_headers is null, and throwing an error on theme.php line 1037. Maybe check it before the loop?
#4
@
12 years ago
This should take care of it:
if ( $_wp_default_headers ) { foreach ( $_wp_default_headers as $header => $details ) { $url = vsprintf( $details['url'], $directory_args ); if ( $default_image == $url ) { $data = $details; $data['url'] = $url; $data['thumbnail_url'] = vsprintf( $data['thumbnail_url'], $directory_args ); break; } } }
#6
follow-up:
↓ 7
@
12 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Are you using a default header as in 'default-image' => $something
, but not actually registering any headers with register_default_headers()? It looks like we support this (see Custom_Header::reset_header_image()), so we can make an adjustment. Patch incoming.
#7
in reply to:
↑ 6
@
12 years ago
Replying to nacin:
Are you using a default header as in
'default-image' => $something
, but not actually registering any headers with register_default_headers()? It looks like we support this (see Custom_Header::reset_header_image()), so we can make an adjustment. Patch incoming.
That is exactly how I am doing it. I set the default-image in the add_theme_support() array argument, without using register_default_headers().
Debug left in - best tested with Twenty Ten, as it has a default-image.