Customizer: Minimize duplicate header crops in the media library.

This adds `Custom_Image_Header::get_previous_crop()`, which finds any
previously cropped headers created from the same base image and replaces
that attachment rather than creating a new attachment.

After updating a crop, the replaced images is also removed from the list
of previous header images in the Customizer.

See #21819.


git-svn-id: https://develop.svn.wordpress.org/trunk@41732 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Joe McGill
2017-10-04 14:58:07 +00:00
parent d77da9cd2a
commit 59c0329461
4 changed files with 100 additions and 2 deletions

View File

@@ -1214,6 +1214,7 @@ function get_uploaded_header_images() {
$header_images[$header_index]['url'] = $url;
$header_images[$header_index]['thumbnail_url'] = $url;
$header_images[$header_index]['alt_text'] = get_post_meta( $header->ID, '_wp_attachment_image_alt', true );
$header_images[$header_index]['attachment_parent'] = (int) get_post_meta( $header->ID, '_wp_attachment_parent', true );
if ( isset( $header_data['width'] ) )
$header_images[$header_index]['width'] = $header_data['width'];