From e351422c7032b6e26a3edf0710774b0a02e71d3d Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Sat, 7 Feb 2026 19:45:51 -0600 Subject: [PATCH 1/3] Use role=button on featured image set and remove, handle space/enter. --- src/js/_enqueues/wp/media/editor.js | 30 ++++++++++++++++++++--------- src/wp-admin/includes/post.php | 4 ++-- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/js/_enqueues/wp/media/editor.js b/src/js/_enqueues/wp/media/editor.js index 02c993fd4bbef..22ca00411b041 100644 --- a/src/js/_enqueues/wp/media/editor.js +++ b/src/js/_enqueues/wp/media/editor.js @@ -703,15 +703,27 @@ * Update the featured image id when the 'remove' link is clicked. */ init: function() { - $('#postimagediv').on( 'click', '#set-post-thumbnail', function( event ) { - event.preventDefault(); - // Stop propagation to prevent thickbox from activating. - event.stopPropagation(); - - wp.media.featuredImage.frame().open(); - }).on( 'click', '#remove-post-thumbnail', function() { - wp.media.featuredImage.remove(); - return false; + $('#postimagediv').on( 'click keyup keydown', '#set-post-thumbnail', function( event ) { + if ( + event.type === 'keyup' && event.key === ' ' + || event.type === 'keydown' && event.key === 'Enter' + || event.type === 'click' + ) { + event.preventDefault(); + // Stop propagation to prevent thickbox from activating. + event.stopPropagation(); + + wp.media.featuredImage.frame().open(); + } + }).on( 'click keyup keydown', '#remove-post-thumbnail', function(event) { + if ( + event.type === 'keyup' && event.key === ' ' + || event.type === 'keydown' && event.key === 'Enter' + || event.type === 'click' + ) { + wp.media.featuredImage.remove(); + return false; + } }); } }; diff --git a/src/wp-admin/includes/post.php b/src/wp-admin/includes/post.php index eb0029a556169..de5aa4fb7d0fa 100644 --- a/src/wp-admin/includes/post.php +++ b/src/wp-admin/includes/post.php @@ -1644,7 +1644,7 @@ function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) { $post = get_post( $post ); $post_type_object = get_post_type_object( $post->post_type ); - $set_thumbnail_link = '

%s

'; + $set_thumbnail_link = '

%s

'; $upload_iframe_src = get_upload_iframe_src( 'image', $post->ID ); $content = sprintf( @@ -1683,7 +1683,7 @@ function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) { $thumbnail_html ); $content .= '

' . __( 'Click the image to edit or update' ) . '

'; - $content .= '

' . esc_html( $post_type_object->labels->remove_featured_image ) . '

'; + $content .= '

' . esc_html( $post_type_object->labels->remove_featured_image ) . '

'; } } From 91adf7c4a851075245e17c0a3e5c998c6adadc00 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Sun, 8 Feb 2026 12:10:13 -0600 Subject: [PATCH 2/3] Add parentheses and collapse line breaks --- src/js/_enqueues/wp/media/editor.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/js/_enqueues/wp/media/editor.js b/src/js/_enqueues/wp/media/editor.js index 22ca00411b041..5e01774119487 100644 --- a/src/js/_enqueues/wp/media/editor.js +++ b/src/js/_enqueues/wp/media/editor.js @@ -704,11 +704,7 @@ */ init: function() { $('#postimagediv').on( 'click keyup keydown', '#set-post-thumbnail', function( event ) { - if ( - event.type === 'keyup' && event.key === ' ' - || event.type === 'keydown' && event.key === 'Enter' - || event.type === 'click' - ) { + if ( ( event.type === 'keyup' && event.key === ' ' ) || ( event.type === 'keydown' && event.key === 'Enter' ) || event.type === 'click' ) { event.preventDefault(); // Stop propagation to prevent thickbox from activating. event.stopPropagation(); @@ -716,11 +712,7 @@ wp.media.featuredImage.frame().open(); } }).on( 'click keyup keydown', '#remove-post-thumbnail', function(event) { - if ( - event.type === 'keyup' && event.key === ' ' - || event.type === 'keydown' && event.key === 'Enter' - || event.type === 'click' - ) { + if ( ( event.type === 'keyup' && event.key === ' ' ) || ( event.type === 'keydown' && event.key === 'Enter' ) || event.type === 'click' ) { wp.media.featuredImage.remove(); return false; } From 4760582fe566366f9729a55dd088f2d7243952f7 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Mon, 9 Feb 2026 13:18:48 -0600 Subject: [PATCH 3/3] Apply suggestion from @mukeshpanchal27 Co-authored-by: Mukesh Panchal --- src/js/_enqueues/wp/media/editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/_enqueues/wp/media/editor.js b/src/js/_enqueues/wp/media/editor.js index 5e01774119487..1097bca966fdb 100644 --- a/src/js/_enqueues/wp/media/editor.js +++ b/src/js/_enqueues/wp/media/editor.js @@ -711,7 +711,7 @@ wp.media.featuredImage.frame().open(); } - }).on( 'click keyup keydown', '#remove-post-thumbnail', function(event) { + }).on( 'click keyup keydown', '#remove-post-thumbnail', function( event ) { if ( ( event.type === 'keyup' && event.key === ' ' ) || ( event.type === 'keydown' && event.key === 'Enter' ) || event.type === 'click' ) { wp.media.featuredImage.remove(); return false;