Make WordPress Core

Ticket #47456: 47456-alt-ui-clarity.patch.txt

File 47456-alt-ui-clarity.patch.txt, 993 bytes (added by mhmda81, 3 months ago)

Adds a placeholder and help text to the alt text field in the media modal to clarify that alt text is context-dependent. Includes a link to the W3C Alt Text Decision Tree. This is a non-breaking, reversible UI improvement as suggested in comment:55.

Line 
1Index: wp-admin/includes/media.php
2===================================================================
3--- wp-admin/includes/media.php (revision 58923)
4+++ wp-admin/includes/media.php (working copy)
5@@ -456,6 +456,13 @@
6 function wp_media_attach_alt_text( $form_fields, $post ) {
7 if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) {
8 $form_fields['post_excerpt']['label'] = __( 'Alternative Text' );
9+ // Add a placeholder to clarify that alt text is context-dependent.
10+ $form_fields['post_excerpt']['placeholder'] = __( 'Describe the purpose of this image in this specific context.' );
11+ // Add help text with a link to the W3C Alt Text Decision Tree.
12+ $form_fields['post_excerpt']['help'] = sprintf(
13+ __( 'Alt text describes the image\'s purpose, not just its appearance. <a href="%s" target="_blank">Learn more</a> about writing good alt text. Leave empty if decorative.' ),
14+ 'https://www.w3.org/WAI/tutorials/images/decision-tree/'
15+ );
16 }
17 return $form_fields;
18 }