[wp-trac] [WordPress Trac] #46134: Allow filtering of `$header` object in `get_header_image_tag()` function (for custom header image override)

WordPress Trac noreply at wordpress.org
Tue Jan 29 14:58:22 UTC 2019


#46134: Allow filtering of `$header` object in `get_header_image_tag()` function
(for custom header image override)
-----------------------------------+------------------------------
 Reporter:  webmandesign           |       Owner:  (none)
     Type:  enhancement            |      Status:  new
 Priority:  normal                 |   Milestone:  Awaiting Review
Component:  Media                  |     Version:  5.0.3
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |     Focuses:
-----------------------------------+------------------------------
Changes (by webmandesign):

 * keywords:  has-patch => has-patch 2nd-opinion


Comment:

 After applying the filter hook in the above patch I realize, it would be
 better to filter actual
 [https://developer.wordpress.org/reference/functions/get_custom_header/
 get_custom_header()] function output.

 **But**, there is a caveats doing so: the object's `url` parameter is
 overridden in
 [https://developer.wordpress.org/reference/functions/get_header_image_tag/
 get_header_image_tag()] function with `$header->url = get_header_image();`
 code and we will need to filter that one too...

 I'm not really sure whether this would be possible, but if the `url`
 parameter in
 [https://developer.wordpress.org/reference/functions/get_custom_header/
 get_custom_header()] is set directly to `get_header_image()` value, we
 could simply apply the new filter hook on the `get_custom_header()` output
 object. In that case my patch would be unnecessary as well as the
 `$header->url = get_header_image();` in `get_header_image_tag()`).

 Anybody can provide some insight on this, whether such solution would be
 more preferable, and most of all, whether it could work without issues?
 Thanks!

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


More information about the wp-trac mailing list