Make WordPress Core


Ignore:
Timestamp:
07/07/2020 01:43:43 PM (6 years ago)
Author:
afercia
Message:

Accessibility: Media: Improve accessibility of the status and error messages in the Image Editor.

  • improves focus management by moving focus to the notices, if any, or to the first "tabbable" element
  • this avoids a focus loss and helps Braille-only and screen magnification users to be aware of the messages
  • adds an ARIA role alert to all the notices
  • uses wp.a11y.speak() to announce messages to assistive technology
  • this way, all visual users will see the messages while assistive technology users will get an audible message
  • uses wp.i18n for translatable strings in wp-admin/js/image-edit.js

Props anevins, ryanshoover, antpb, SergeyBiryukov, afercia.
See #20491.
Fixes #47147.

File:
1 edited

Legend:

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

    r48373 r48375  
    26082608                case 'save':
    26092609                        $msg = wp_save_image( $attachment_id );
    2610                         $msg = wp_json_encode( $msg );
    2611                         wp_die( $msg );
     2610                        if ( $msg->error ) {
     2611                                wp_send_json_error( $msg );
     2612                        }
     2613
     2614                        wp_send_json_success( $msg );
    26122615                        break;
    26132616                case 'scale':
     
    26192622        }
    26202623
     2624        ob_start();
    26212625        wp_image_editor( $attachment_id, $msg );
    2622         wp_die();
     2626        $html = ob_get_clean();
     2627
     2628        if ( $msg->error ) {
     2629                wp_send_json_error(
     2630                        array(
     2631                                'message' => $msg,
     2632                                'html'    => $html,
     2633                        )
     2634                );
     2635        }
     2636
     2637        wp_send_json_success(
     2638                array(
     2639                        'message' => $msg,
     2640                        'html'    => $html,
     2641                )
     2642        );
    26232643}
    26242644
Note: See TracChangeset for help on using the changeset viewer.