Changeset 55935 for trunk/src/wp-admin/includes/image-edit.php
- Timestamp:
- 06/18/2023 02:22:40 PM (20 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/image-edit.php
r55919 r55935 44 44 } 45 45 } 46 $edit_custom_sizes = false; 46 47 47 /** 48 * Filters whether custom sizes are available options for image editing.48 * Shows the settings in the Image Editor that allow selecting to edit only the thumbnail of an image. 49 49 * 50 * @since 6. 0.050 * @since 6.3.0 51 51 * 52 * @param bool |string[] $edit_custom_sizes True if custom sizes can be edited or array of custom size names.52 * @param bool Whether to show the settings in the Image Editor. Default false. 53 53 */ 54 $edit_custom_sizes = apply_filters( 'edit_custom_thumbnail_sizes', $edit_custom_sizes ); 54 $edit_thumbnails_separately = (bool) apply_filters( 'image_edit_thumbnails_separately', false ); 55 55 56 ?> 56 57 <div class="imgedit-wrap wp-clearfix"> … … 273 274 274 275 <?php 275 if ( $ thumb && $sub_sizes ) {276 if ( $edit_thumbnails_separately && $thumb && $sub_sizes ) { 276 277 $thumb_img = wp_constrain_dimensions( $thumb['width'], $thumb['height'], 160, 120 ); 277 278 ?> … … 308 309 <label for="imgedit-target-thumbnail"><?php _e( 'Thumbnail' ); ?></label> 309 310 </span> 310 311 311 312 <span class="imgedit-label"> 312 313 <input type="radio" id="imgedit-target-nothumb" name="imgedit-target-<?php echo $post_id; ?>" value="nothumb" /> … … 314 315 </span> 315 316 316 <?php317 if ( $edit_custom_sizes ) {318 if ( ! is_array( $edit_custom_sizes ) ) {319 $edit_custom_sizes = get_intermediate_image_sizes();320 }321 foreach ( array_unique( $edit_custom_sizes ) as $key => $size ) {322 if ( array_key_exists( $size, $meta['sizes'] ) ) {323 if ( 'thumbnail' === $size ) {324 continue;325 }326 ?>327 <span class="imgedit-label">328 <input type="radio" id="imgedit-target-custom<?php echo esc_attr( $key ); ?>" name="imgedit-target-<?php echo $post_id; ?>" value="<?php echo esc_attr( $size ); ?>" />329 <label for="imgedit-target-custom<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $size ); ?></label>330 </span>331 <?php332 }333 }334 }335 ?>336 317 </fieldset> 337 318 </div> … … 919 900 $scale = ! empty( $_REQUEST['do'] ) && 'scale' === $_REQUEST['do']; 920 901 902 /** This filter is documented in wp-admin/includes/image-edit.php */ 903 $edit_thumbnails_separately = (bool) apply_filters( 'image_edit_thumbnails_separately', false ); 904 921 905 if ( $scale ) { 922 906 $size = $img->get_size(); … … 978 962 isset( $backup_sizes['full-orig'] ) && $backup_sizes['full-orig']['file'] != $basename ) { 979 963 980 if ( 'thumbnail' === $target ) {964 if ( $edit_thumbnails_separately && 'thumbnail' === $target ) { 981 965 $new_path = "{$dirname}/{$filename}-temp.{$ext}"; 982 966 } else { … … 1028 1012 $meta['height'] = $size['height']; 1029 1013 1030 if ( $success ) {1014 if ( $success && ( 'nothumb' === $target || 'all' === $target ) ) { 1031 1015 $sizes = get_intermediate_image_sizes(); 1032 if ( 'nothumb' === $target || 'all' === $target ) { 1033 if ( 'nothumb' === $target ) { 1034 $sizes = array_diff( $sizes, array( 'thumbnail' ) ); 1035 } 1036 } elseif ( 'thumbnail' !== $target ) { 1037 $sizes = array_diff( $sizes, array( $target ) ); 1016 1017 if ( $edit_thumbnails_separately && 'nothumb' === $target ) { 1018 $sizes = array_diff( $sizes, array( 'thumbnail' ) ); 1038 1019 } 1039 1020 } … … 1041 1022 $return->fw = $meta['width']; 1042 1023 $return->fh = $meta['height']; 1043 } elseif ( 'thumbnail' === $target ) {1024 } elseif ( $edit_thumbnails_separately && 'thumbnail' === $target ) { 1044 1025 $sizes = array( 'thumbnail' ); 1045 1026 $success = true; 1046 1027 $delete = true; 1047 1028 $nocrop = true; 1048 } else {1049 $sizes = array( $target );1050 $success = true;1051 $delete = true;1052 $nocrop = $_wp_additional_image_sizes[ $size ]['crop'];1053 1029 } 1054 1030
Note: See TracChangeset
for help on using the changeset viewer.