mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
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. Built from https://develop.svn.wordpress.org/trunk@56411 git-svn-id: http://core.svn.wordpress.org/trunk@55923 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3e1db7f59d
commit
3fa176f4fe
@ -32,6 +32,7 @@ function wp_image_editor( $post_id, $msg = false ) {
|
|||||||
|
|
||||||
$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
|
$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
|
||||||
$can_restore = false;
|
$can_restore = false;
|
||||||
|
|
||||||
if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) {
|
if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) {
|
||||||
$can_restore = wp_basename( $meta['file'] ) !== $backup_sizes['full-orig']['file'];
|
$can_restore = wp_basename( $meta['file'] ) !== $backup_sizes['full-orig']['file'];
|
||||||
}
|
}
|
||||||
@ -897,8 +898,8 @@ function wp_save_image( $post_id ) {
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fwidth = ! empty( $_REQUEST['fwidth'] ) ? (int) $_REQUEST['fwidth'] : 0;
|
$full_width = ! empty( $_REQUEST['fwidth'] ) ? (int) $_REQUEST['fwidth'] : 0;
|
||||||
$fheight = ! empty( $_REQUEST['fheight'] ) ? (int) $_REQUEST['fheight'] : 0;
|
$full_height = ! empty( $_REQUEST['fheight'] ) ? (int) $_REQUEST['fheight'] : 0;
|
||||||
$target = ! empty( $_REQUEST['target'] ) ? preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['target'] ) : '';
|
$target = ! empty( $_REQUEST['target'] ) ? preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['target'] ) : '';
|
||||||
$scale = ! empty( $_REQUEST['do'] ) && 'scale' === $_REQUEST['do'];
|
$scale = ! empty( $_REQUEST['do'] ) && 'scale' === $_REQUEST['do'];
|
||||||
|
|
||||||
@ -907,20 +908,20 @@ function wp_save_image( $post_id ) {
|
|||||||
|
|
||||||
if ( $scale ) {
|
if ( $scale ) {
|
||||||
$size = $img->get_size();
|
$size = $img->get_size();
|
||||||
$sX = $size['width'];
|
$original_width = $size['width'];
|
||||||
$sY = $size['height'];
|
$original_height = $size['height'];
|
||||||
|
|
||||||
if ( $sX < $fwidth || $sY < $fheight ) {
|
if ( $full_width > $original_width || $full_height > $original_height ) {
|
||||||
$return->error = esc_js( __( 'Images cannot be scaled to a size larger than the original.' ) );
|
$return->error = esc_js( __( 'Images cannot be scaled to a size larger than the original.' ) );
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $fwidth > 0 && $fheight > 0 ) {
|
if ( $full_width > 0 && $full_height > 0 ) {
|
||||||
// Check if it has roughly the same w / h ratio.
|
// Check if it has roughly the same w / h ratio.
|
||||||
$diff = round( $sX / $sY, 2 ) - round( $fwidth / $fheight, 2 );
|
$diff = round( $original_width / $original_height, 2 ) - round( $full_width / $full_height, 2 );
|
||||||
if ( -0.1 < $diff && $diff < 0.1 ) {
|
if ( -0.1 < $diff && $diff < 0.1 ) {
|
||||||
// Scale the full size image.
|
// Scale the full size image.
|
||||||
if ( $img->resize( $fwidth, $fheight ) ) {
|
if ( $img->resize( $full_width, $full_height ) ) {
|
||||||
$scaled = true;
|
$scaled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.4-alpha-56410';
|
$wp_version = '6.4-alpha-56411';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user