Changeset 56400
- Timestamp:
- 08/16/2023 02:03:44 PM (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/image-edit.php
r56277 r56400 637 637 unset( $obj->c ); 638 638 } 639 639 640 $changes[ $key ] = $obj; 640 641 } … … 643 644 if ( count( $changes ) > 1 ) { 644 645 $filtered = array( $changes[0] ); 646 645 647 for ( $i = 0, $j = 1, $c = count( $changes ); $j < $c; $j++ ) { 646 648 $combined = false; 647 if ( $filtered[ $i ]->type == $changes[ $j ]->type ) { 649 650 if ( $filtered[ $i ]->type === $changes[ $j ]->type ) { 648 651 switch ( $filtered[ $i ]->type ) { 649 652 case 'rotate': … … 657 660 } 658 661 } 662 659 663 if ( ! $combined ) { 660 664 $filtered[ ++$i ] = $changes[ $j ]; 661 665 } 662 666 } 667 663 668 $changes = $filtered; 664 669 unset( $filtered ); … … 694 699 switch ( $operation->type ) { 695 700 case 'rotate': 696 if ( 0 != $operation->angle ) {701 if ( 0 !== $operation->angle ) { 697 702 if ( $image instanceof WP_Image_Editor ) { 698 703 $image->rotate( $operation->angle ); … … 703 708 break; 704 709 case 'flip': 705 if ( 0 != $operation->axis ) {710 if ( 0 !== $operation->axis ) { 706 711 if ( $image instanceof WP_Image_Editor ) { 707 $image->flip( ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 );712 $image->flip( ( $operation->axis & 1 ) !== 0, ( $operation->axis & 2 ) !== 0 ); 708 713 } else { 709 $image = _flip_image_resource( $image, ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 );714 $image = _flip_image_resource( $image, ( $operation->axis & 1 ) !== 0, ( $operation->axis & 2 ) !== 0 ); 710 715 } 711 716 } … … 802 807 $data = $backup_sizes['full-orig']; 803 808 804 if ( $parts['basename'] != $data['file'] ) {809 if ( $parts['basename'] !== $data['file'] ) { 805 810 if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE ) { 806 807 811 // Delete only if it's an edited image. 808 812 if ( preg_match( '/-e[0-9]{13}\./', $parts['basename'] ) ) { … … 829 833 if ( isset( $backup_sizes[ "$default_size-orig" ] ) ) { 830 834 $data = $backup_sizes[ "$default_size-orig" ]; 831 if ( isset( $meta['sizes'][ $default_size ] ) && $meta['sizes'][ $default_size ]['file'] != $data['file'] ) { 835 836 if ( isset( $meta['sizes'][ $default_size ] ) && $meta['sizes'][ $default_size ]['file'] !== $data['file'] ) { 832 837 if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE ) { 833 834 838 // Delete only if it's an edited image. 835 839 if ( preg_match( '/-e[0-9]{13}-/', $meta['sizes'][ $default_size ]['file'] ) ) { … … 848 852 } 849 853 850 if ( ! wp_update_attachment_metadata( $post_id, $meta ) ||851 ( $old_backup_sizes !== $backup_sizes && ! update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes ) ) ) {852 854 if ( ! wp_update_attachment_metadata( $post_id, $meta ) 855 || ( $old_backup_sizes !== $backup_sizes && ! update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes ) ) 856 ) { 853 857 $msg->error = __( 'Cannot save image metadata.' ); 854 858 return $msg; … … 859 863 } else { 860 864 $msg->msg = __( 'Image restored successfully.' ); 865 861 866 if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE ) { 862 867 delete_post_meta( $post_id, '_wp_attachment_backup_sizes' ); … … 887 892 888 893 $img = wp_get_image_editor( _load_image_to_edit_path( $post_id, 'full' ) ); 894 889 895 if ( is_wp_error( $img ) ) { 890 896 $return->error = esc_js( __( 'Unable to create new image.' ) ); … … 956 962 $suffix = time() . rand( 100, 999 ); 957 963 958 if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE && 959 isset( $backup_sizes['full-orig'] ) && $backup_sizes['full-orig']['file'] != $basename ) { 964 if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE 965 && isset( $backup_sizes['full-orig'] ) && $backup_sizes['full-orig']['file'] !== $basename 966 ) { 960 967 961 968 if ( $edit_thumbnails_separately && 'thumbnail' === $target ) { … … 970 977 $new_filename = "{$filename}.{$ext}"; 971 978 $new_path = "{$dirname}/$new_filename"; 979 972 980 if ( file_exists( $new_path ) ) { 973 981 $suffix++; … … 986 994 if ( 'nothumb' === $target || 'all' === $target || 'full' === $target || $scaled ) { 987 995 $tag = false; 996 988 997 if ( isset( $backup_sizes['full-orig'] ) ) { 989 if ( ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) && $backup_sizes['full-orig']['file'] !== $basename ) { 998 if ( ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) 999 && $backup_sizes['full-orig']['file'] !== $basename 1000 ) { 990 1001 $tag = "full-$suffix"; 991 1002 } … … 1001 1012 ); 1002 1013 } 1014 1003 1015 $success = ( $path === $new_path ) || update_attached_file( $post_id, $new_path ); 1004 1016 … … 1046 1058 foreach ( $sizes as $size ) { 1047 1059 $tag = false; 1060 1048 1061 if ( isset( $meta['sizes'][ $size ] ) ) { 1049 1062 if ( isset( $backup_sizes[ "$size-orig" ] ) ) { 1050 if ( ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) && $backup_sizes[ "$size-orig" ]['file'] != $meta['sizes'][ $size ]['file'] ) { 1063 if ( ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) 1064 && $backup_sizes[ "$size-orig" ]['file'] !== $meta['sizes'][ $size ]['file'] 1065 ) { 1051 1066 $tag = "$size-$suffix"; 1052 1067 } … … 1089 1104 // Check if it's an image edit from attachment edit screen. 1090 1105 if ( ! empty( $_REQUEST['context'] ) && 'edit-attachment' === $_REQUEST['context'] ) { 1091 $thumb_url = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true ); 1106 $thumb_url = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true ); 1107 1092 1108 $return->thumbnail = $thumb_url[0]; 1093 1109 } else { 1094 1110 $file_url = wp_get_attachment_url( $post_id ); 1111 1095 1112 if ( ! empty( $meta['sizes']['thumbnail'] ) ) { 1096 1113 $thumb = $meta['sizes']['thumbnail']; … … 1110 1127 1111 1128 $return->msg = esc_js( __( 'Image saved' ) ); 1129 1112 1130 return $return; 1113 1131 }
Note: See TracChangeset
for help on using the changeset viewer.