Make WordPress Core

Ticket #21819: 21819.2.diff

File 21819.2.diff, 1.9 KB (added by joemcgill, 8 years ago)
  • src/wp-admin/custom-header.php

    diff --git src/wp-admin/custom-header.php src/wp-admin/custom-header.php
    index 8b2973fc11..aa6d619625 100644
    wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?> 
    11871187                $attachment_id = wp_insert_attachment( $object, $cropped );
    11881188                $metadata = wp_generate_attachment_metadata( $attachment_id, $cropped );
    11891189
     1190                // If this is a crop, save the original attachment ID as metadata.
     1191                if ( $parent_id ) {
     1192                        $metadata['attachment_parent'] = $parent_id;
     1193                }
     1194               
    11901195                /**
    11911196                 * Filters the header image attachment metadata.
    11921197                 *
    wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?> 
    11971202                 * @param array $metadata Attachment metadata.
    11981203                 */
    11991204                $metadata = apply_filters( 'wp_header_image_attachment_metadata', $metadata );
    1200                 wp_update_attachment_metadata( $attachment_id, $metadata );
    12011205
    1202                 if ( $parent_id ) {
    1203                         $meta = add_post_meta( $attachment_id, '_wp_attachment_parent', $parent_id, true );
    1204                 }
     1206                wp_update_attachment_metadata( $attachment_id, $metadata );
    12051207
    12061208                return $attachment_id;
    12071209        }
  • src/wp-includes/theme.php

    diff --git src/wp-includes/theme.php src/wp-includes/theme.php
    index 2ee66fbddf..e84af8b385 100644
    function get_uploaded_header_images() { 
    12141214                $header_images[$header_index]['url'] =  $url;
    12151215                $header_images[$header_index]['thumbnail_url'] = $url;
    12161216                $header_images[$header_index]['alt_text'] = get_post_meta( $header->ID, '_wp_attachment_image_alt', true );
    1217                 $header_images[$header_index]['attachment_parent'] = (int) get_post_meta( $header->ID, '_wp_attachment_parent', true );
     1217                $header_images[$header_index]['attachment_parent'] = isset( $header_data['attachment_parent'] ) ? $header_data['attachment_parent'] : '';
    12181218
    12191219                if ( isset( $header_data['width'] ) )
    12201220                        $header_images[$header_index]['width'] = $header_data['width'];