Skip to content

Commit 433f91b

Browse files
SergeyBiryukovpull[bot]
authored andcommitted
Coding Standards: Improve variable names in wp_save_image().
This resolves a few WPCS warnings: {{{ Variable "$sX" is not in valid snake_case format, try "$s_x" Variable "$sY" is not in valid snake_case format, try "$s_y" }}} The `$sX` and `$sY` variables are renamed to `$original_width` and `$original_height`, respectively. Additionally, the `$fwidth` and `$fheight` variables are renamed to `$full_width` and `$full_height`, for clarity. Follow-up to [11965], [22094], [56400]. See #58831. git-svn-id: https://develop.svn.wordpress.org/trunk@56411 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 73c9fa1 commit 433f91b

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/wp-admin/includes/image-edit.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function wp_image_editor( $post_id, $msg = false ) {
3232

3333
$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
3434
$can_restore = false;
35+
3536
if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) {
3637
$can_restore = wp_basename( $meta['file'] ) !== $backup_sizes['full-orig']['file'];
3738
}
@@ -897,30 +898,30 @@ function wp_save_image( $post_id ) {
897898
return $return;
898899
}
899900

900-
$fwidth = ! empty( $_REQUEST['fwidth'] ) ? (int) $_REQUEST['fwidth'] : 0;
901-
$fheight = ! empty( $_REQUEST['fheight'] ) ? (int) $_REQUEST['fheight'] : 0;
902-
$target = ! empty( $_REQUEST['target'] ) ? preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['target'] ) : '';
903-
$scale = ! empty( $_REQUEST['do'] ) && 'scale' === $_REQUEST['do'];
901+
$full_width = ! empty( $_REQUEST['fwidth'] ) ? (int) $_REQUEST['fwidth'] : 0;
902+
$full_height = ! empty( $_REQUEST['fheight'] ) ? (int) $_REQUEST['fheight'] : 0;
903+
$target = ! empty( $_REQUEST['target'] ) ? preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['target'] ) : '';
904+
$scale = ! empty( $_REQUEST['do'] ) && 'scale' === $_REQUEST['do'];
904905

905906
/** This filter is documented in wp-admin/includes/image-edit.php */
906907
$edit_thumbnails_separately = (bool) apply_filters( 'image_edit_thumbnails_separately', false );
907908

908909
if ( $scale ) {
909-
$size = $img->get_size();
910-
$sX = $size['width'];
911-
$sY = $size['height'];
910+
$size = $img->get_size();
911+
$original_width = $size['width'];
912+
$original_height = $size['height'];
912913

913-
if ( $sX < $fwidth || $sY < $fheight ) {
914+
if ( $full_width > $original_width || $full_height > $original_height ) {
914915
$return->error = esc_js( __( 'Images cannot be scaled to a size larger than the original.' ) );
915916
return $return;
916917
}
917918

918-
if ( $fwidth > 0 && $fheight > 0 ) {
919+
if ( $full_width > 0 && $full_height > 0 ) {
919920
// Check if it has roughly the same w / h ratio.
920-
$diff = round( $sX / $sY, 2 ) - round( $fwidth / $fheight, 2 );
921+
$diff = round( $original_width / $original_height, 2 ) - round( $full_width / $full_height, 2 );
921922
if ( -0.1 < $diff && $diff < 0.1 ) {
922923
// Scale the full size image.
923-
if ( $img->resize( $fwidth, $fheight ) ) {
924+
if ( $img->resize( $full_width, $full_height ) ) {
924925
$scaled = true;
925926
}
926927
}

0 commit comments

Comments
 (0)