[wp-trac] [WordPress Trac] #60524: Cropping site icon should preserve attachment properties

WordPress Trac noreply at wordpress.org
Tue Feb 13 13:36:07 UTC 2024


#60524: Cropping site icon should preserve attachment properties
---------------------------+-----------------------------
 Reporter:  afercia        |      Owner:  (none)
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Media          |    Version:
 Severity:  normal         |   Keywords:
  Focuses:  accessibility  |
---------------------------+-----------------------------
 Follow-up to #37750 / [53027]
 See #54370 / [57602]

 In [53027], a bug was fixed where newly generated cropped images didn't
 copied over some meta data from the original image like the alt text and
 caption.

 The code that fixed the bug was added in the `wp_ajax_crop_image()`
 function but it turns out it was added in the `default` case of
 [https://github.com/WordPress/wordpress-
 develop/blob/8c6a1db3120ea63165b4485c56820483403aefc1/src/wp-
 admin/includes/ajax-actions.php#L4021-L4133 the big switch statement] in
 that function.

 As such, the meta data are copied over only for the default case, which
 includes the cropping of the WP logo, but they aren't copied over for the
 `site-icon` case.

 It could be argued that the site icon image doesn't need the alt text or
 the caption because it is used in the browsers' UI. However, it would be
 best to always copy over these data to any cropped image for at least two
 reasons:

 - Cropping an image will generate a new image that is added to the Media
 Library. It's good that the new image preserves all the data from the
 original image.
 - These meta data are useful in the admin interface. For example now that
 [57602] adds a site icon UI in the admin General Settings page, the UI
 needs the alt text of the site icon image to inform users what the
 currently selected image is. This would be even more important for screen
 reader users as the current implementation in [57602] doesn't provide any
 textual information about the currently selected image.

 The inconsistency in copying over the meta data can be tested also in the
 Customizer or in the new UI from [57602].

 To reproduce:
 - Set Twenty Twenty-One as active theme so that the Customiser is
 available.
 - Go to the Customizer > Site Identity.
 - Set a Logo image: make sure to select an image that is large enough to
 be cropped and that does have an alt text.
 - Once the image gets cropped and set as logo, open the Media Library
 again.
 - Observe there's a new copped image.
 - Select the cropped image and observe in the right side of the media
 modal dialog that the original alt text (and caption if originally
 present) has been copied to the new image.
 - Close the media modal dialog.
 - In the Customizer set a Site Icon, repeating the steps above.
 - Once the image gets cropped and set as site icon, open the Media Library
 again.
 - Observe there's a new copped image.
 - Select the new image and observe the original alt text (and caption if
 any) hasn't been copied to the new image.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60524>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list