// Delete the temporary cropped file, we don't need it.
wp_delete_file( $cropped );
// Additional sizes in wp_prepare_attachment_for_js().
add_filter( 'image_size_names_choose', array
( $wp_site_icon, 'additional_sizes'
) );
break;
} /** This filter is documented in wp-admin/includes/class-custom-image-header.php */
$cropped =
apply_filters( 'wp_create_file_in_uploads',
$cropped,
$attachment_id ); // For replication.
$attachment =
$wp_site_icon->
create_attachment_object( $cropped,
$attachment_id );
unset( $attachment['ID'
] );
// Update the attachment.
add_filter( 'intermediate_image_sizes_advanced', array
( $wp_site_icon, 'additional_sizes'
) );
$attachment_id =
$wp_site_icon->
insert_attachment( $attachment,
$cropped );
remove_filter( 'intermediate_image_sizes_advanced', array
( $wp_site_icon, 'additional_sizes'
) );
// Additional sizes in wp_prepare_attachment_for_js().
add_filter( 'image_size_names_choose', array
( $wp_site_icon, 'additional_sizes'
) );
break;