[wp-trac] [WordPress Trac] #31786: Customizer: current header image does not show when it has the same name as another header image
WordPress Trac
noreply at wordpress.org
Sun Mar 29 20:50:19 UTC 2015
#31786: Customizer: current header image does not show when it has the same name as
another header image
--------------------------+------------------------------
Reporter: sirbrillig | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Customize | Version: trunk
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by sirbrillig):
Modifying `get_uploaded_header_images` to use the attachment ID as the
array key successfully fixes the issue in the Customizer, but using the
header image basename as the key is done in several other places that rely
on that function. Let's examine them.
1. `Custom_Image_Header->show_header_selector`
This outputs HTML of available headers, using the keys of the array
returned by `get_uploaded_header_images` as the radio button values, which
are then used to save the header image elsewhere
(`WP_Customize_Header_Image_Setting->update` which then calls
`Custom_Image_Header->set_header_image`). This should be fine if we switch
to using the attachment ID as the key because `set_header_image` uses the
same data (see below).
2. `Custom_Image_Header->set_header_image`
...which reads in its description that it accepts as its parameter:
> the key of an image uploaded for that theme (the basename of the URL).
And indeed it compares the parameter to the keys of the array returned by
`get_uploaded_header_images`. This would work fine if the keys were
changed to use the attachment ID, I think, as long as the docs were
changed to reflect that, because this is called only by
`WP_Customize_Header_Image_Setting->update` which gets its values from
`get_uploaded_header_images` as well.
3. `Custom_Image_Header->get_uploaded_header_images`
This also returns the results of `get_uploaded_header_images` (although it
is quite happy to return them with different keys). The results of that
function then get bootstrapped into the Javascript of the Customizer as
`_wpCustomizeHeader.uploads`, which is used to construct the model
`api.HeaderTool.ChoiceList`. There, the key (still currently the header
image basename) is used as the attribute `header.defaultName` and is used
for saving, but only if there is no attachment ID, so it should not be
affected by changing the keys of attachments to their ID.
Since I don't immediately see a downside, I'll attach a patch below that
makes this change.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/31786#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list