Make WordPress Core


Ignore:
Timestamp:
02/12/2026 01:50:20 AM (4 months ago)
Author:
joedolson
Message:

Editor: A11y: Fix featured image control naming.

The controls to set and remove a featured image in the Classic Editor use a link with no attributes to identify purpose. Triggering a modal dialog should be done using a button with proper identification.

Add role="button", aria-haspopup="dialog", and aria-controls attributes to give users appropriate information about the control behavior. Add keypress handlers for button-specific keyboard events.

Does not use a button element to avoid interfering with style customizations.

Props alh0319, joedolson, mukesh27, huzaifaalmesbah.
Fixes #63980.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/post.php

    r61463 r61616  
    16451645    $post               = get_post( $post );
    16461646    $post_type_object   = get_post_type_object( $post->post_type );
    1647     $set_thumbnail_link = '<p class="hide-if-no-js"><a href="%s" id="set-post-thumbnail"%s class="thickbox">%s</a></p>';
     1647    $set_thumbnail_link = '<p class="hide-if-no-js"><a href="%s" id="set-post-thumbnail"%s class="thickbox" role="button" aria-haspopup="dialog" aria-controls="wp-media-modal">%s</a></p>';
    16481648    $upload_iframe_src  = get_upload_iframe_src( 'image', $post->ID );
    16491649
     
    16841684            );
    16851685            $content .= '<p class="hide-if-no-js howto" id="set-post-thumbnail-desc">' . __( 'Click the image to edit or update' ) . '</p>';
    1686             $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail">' . esc_html( $post_type_object->labels->remove_featured_image ) . '</a></p>';
     1686            $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" role="button">' . esc_html( $post_type_object->labels->remove_featured_image ) . '</a></p>';
    16871687        }
    16881688    }
Note: See TracChangeset for help on using the changeset viewer.