Make WordPress Core


Ignore:
Timestamp:
03/02/2024 08:13:02 PM (2 years ago)
Author:
joedolson
Message:

Media: Accessibility: Copy attachment properties on site icon crop.

Add parity between site icon, custom header, and default image crop behaviors. [53027] fixed a bug where alt text and caption were not copied on custom headers, but did not apply that change in any other context.

Deprecate the create_attachment_object method in the Wp_Site_Icon and Custom_Image_Header classes and replace that functionality with the new function wp_copy_parent_attachment_properties() to improve consistency.

Props afercia, rcreators, jorbin, joedolson, huzaifaalmesbah, shailu25, swissspidy, mukesh27.
Fixes #60524.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/image/siteIcon.php

    r52010 r57755  
    9999    }
    100100
    101     public function test_create_attachment_object() {
    102         $attachment_id = $this->insert_attachment();
    103         $parent_url    = get_post( $attachment_id )->guid;
    104         $cropped       = str_replace( wp_basename( $parent_url ), 'cropped-test-image.jpg', $parent_url );
    105 
    106         $object = $this->wp_site_icon->create_attachment_object( $cropped, $attachment_id );
    107 
    108         $this->assertSame( $object['post_title'], 'cropped-test-image.jpg' );
    109         $this->assertSame( $object['context'], 'site-icon' );
    110         $this->assertSame( $object['post_mime_type'], 'image/jpeg' );
    111         $this->assertSame( $object['post_content'], $cropped );
    112         $this->assertSame( $object['guid'], $cropped );
    113     }
    114 
    115101    public function test_insert_cropped_attachment() {
    116102        $attachment_id = $this->insert_attachment();
     
    118104        $cropped       = str_replace( wp_basename( $parent_url ), 'cropped-test-image.jpg', $parent_url );
    119105
    120         $object     = $this->wp_site_icon->create_attachment_object( $cropped, $attachment_id );
     106        $object     = wp_copy_parent_attachment_properties( $cropped, $attachment_id, 'site-icon' );
    121107        $cropped_id = $this->wp_site_icon->insert_attachment( $object, $cropped );
    122108
Note: See TracChangeset for help on using the changeset viewer.