Make WordPress Core


Ignore:
Timestamp:
10/19/2017 04:17:31 AM (9 years ago)
Author:
joemcgill
Message:

Customizer: Improve handling of crops in the media library.

This is a follow up on r41732, implementing the following improvements:

  • Attachment parent info is now stored in attachment meta rather than a

separate post meta key.

  • Attachments created from contextual crops (e.g. header, logos, etc.) are

filtered out of the media library using a new _filterContext method in
wp.media.controller.Library.

Props joemcgill, westonruter.
See #21819.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/custom-header.php

    r41732 r41937  
    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.
    … …  
    11981203                 */
    11991204                $metadata = apply_filters( 'wp_header_image_attachment_metadata', $metadata );
     1205
    12001206                wp_update_attachment_metadata( $attachment_id, $metadata );
    1201 
    1202                 if ( $parent_id ) {
    1203                         $meta = add_post_meta( $attachment_id, '_wp_attachment_parent', $parent_id, true );
    1204                 }
    12051207
    12061208                return $attachment_id;
Note: See TracChangeset for help on using the changeset viewer.