diff --git a/src/wp-admin/includes/image-edit.php b/src/wp-admin/includes/image-edit.php
index a91f082bb6..6a0324baa8 100644
--- a/src/wp-admin/includes/image-edit.php
+++ b/src/wp-admin/includes/image-edit.php
@@ -43,7 +43,15 @@ function wp_image_editor( $post_id, $msg = false ) {
$note = "
";
}
}
-
+ $edit_custom_sizes = false;
+ /**
+ * Filters whether custom sizes are available options for image editing.
+ *
+ * @since 6.0.0
+ *
+ * @param bool|array $edit_custom_sizes True if custom sizes can be edited or array of custom sizes.
+ */
+ $edit_custom_sizes = apply_filters( 'edit_custom_thumbnail_sizes', $edit_custom_sizes );
?>
@@ -905,10 +933,14 @@ function wp_save_image( $post_id ) {
$meta['width'] = $size['width'];
$meta['height'] = $size['height'];
- if ( $success && ( 'nothumb' === $target || 'all' === $target ) ) {
+ if ( $success ) {
$sizes = get_intermediate_image_sizes();
- if ( 'nothumb' === $target ) {
- $sizes = array_diff( $sizes, array( 'thumbnail' ) );
+ if ( 'nothumb' === $target || 'all' === $target ) {
+ if ( 'nothumb' === $target ) {
+ $sizes = array_diff( $sizes, array( 'thumbnail' ) );
+ }
+ } elseif ( 'thumbnail' !== $target ) {
+ $sizes = array_diff( $sizes, array( $target ) );
}
}
@@ -919,6 +951,11 @@ function wp_save_image( $post_id ) {
$success = true;
$delete = true;
$nocrop = true;
+ } else {
+ $sizes = array( $target );
+ $success = true;
+ $delete = true;
+ $nocrop = $_wp_additional_image_sizes[ $size ]['crop'];
}
/*