Make WordPress Core


Ignore:
Timestamp:
03/02/2024 08:13:02 PM (13 months 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/src/wp-admin/includes/class-custom-image-header.php

    r57364 r57755  
    10781078        $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication.
    10791079
    1080         $attachment = $this->create_attachment_object( $cropped, $attachment_id );
     1080        $attachment = wp_copy_parent_attachment_properties( $cropped, $attachment_id, 'custom-header' );
    10811081
    10821082        if ( ! empty( $_POST['create-new-attachment'] ) ) {
     
    13151315     *
    13161316     * @since 3.9.0
     1317     * @deprecated 6.5.0
    13171318     *
    13181319     * @param string $cropped              Cropped image URL.
     
    13211322     */
    13221323    final public function create_attachment_object( $cropped, $parent_attachment_id ) {
     1324        _deprecated_function( __METHOD__, '6.5.0', 'wp_copy_parent_attachment_properties()' );
    13231325        $parent     = get_post( $parent_attachment_id );
    13241326        $parent_url = wp_get_attachment_url( $parent->ID );
     
    14221424        $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication.
    14231425
    1424         $attachment = $this->create_attachment_object( $cropped, $attachment_id );
     1426        $attachment = wp_copy_parent_attachment_properties( $cropped, $attachment_id, 'custom-header' );
    14251427
    14261428        $previous = $this->get_previous_crop( $attachment );
Note: See TracChangeset for help on using the changeset viewer.