[wp-trac] [WordPress Trac] #46124: Allow setting custom image alt text in custom header image

WordPress Trac noreply at wordpress.org
Wed Jan 30 09:39:26 UTC 2019


#46124: Allow setting custom image alt text in custom header image
-------------------------------------+----------------------------
 Reporter:  webmandesign             |       Owner:  audrasjb
     Type:  enhancement              |      Status:  accepted
 Priority:  normal                   |   Milestone:  5.2
Component:  Media                    |     Version:  5.0.3
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-refresh  |     Focuses:  accessibility
-------------------------------------+----------------------------

Comment (by webmandesign):

 Hi @afercia,

 Yes, you're right, all cropped images WordPress creates are affected by
 #46127.

 In the case of empty alt text the fix could be as simple as setting it
 directly in `$attr` array [#comment:4 as mentioned above].

 But there is still an issue here as the custom header image URL could be
 different from attachment ID in `get_header_image_tag()`. That way the alt
 text is pulled from the attachment ID image, yet a different image could
 be actually displayed... (Look at the first 2 lines of the
 [https://developer.wordpress.org/reference/functions/get_header_image_tag/
 function code].)
 My patch takes care of this issue, but the possibility of different image
 URL indeed complicates things here, which also relates to other ticket
 I've reported (#46134).

 I think the alt text for the custom header image should be pulled from the
 actual image if possible and not overwritten or set empty by default. That
 way user can decide what to do.

 As an example, [https://themedemos.webmandesign.eu/reykjavik/post-8/ in my
 theme on single post] I'm overriding the custom header image with post
 featured image. And there is not an easy way of setting correct image alt
 text for this image now for me if I am using native WordPress
 functionality only. (I will solve this in my themes with a custom code
 eventually, but dealing with the issue I've spotted this discrepancy in WP
 core code.)

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


More information about the wp-trac mailing list