mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-19 00:55:13 +01:00
Media: Fix implicit conversion from float to int in image cropping.
Cast crop values to integers to prevent PHP error caused by implicit conversion from `float` to `int` values when cropping images using ImageMagick. Props skithund, mai21, nicomollet, amanias1977, joedolson. Fixes #59782. Built from https://develop.svn.wordpress.org/trunk@58457 git-svn-id: http://core.svn.wordpress.org/trunk@57906 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
10bccbd392
commit
9360266c51
@ -736,7 +736,7 @@ function image_edit_apply_changes( $image, $changes ) {
|
||||
$h = $size['height'];
|
||||
|
||||
$scale = isset( $sel->r ) ? $sel->r : 1 / _image_get_preview_ratio( $w, $h ); // Discard preview scaling.
|
||||
$image->crop( $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale );
|
||||
$image->crop( (int) ( $sel->x * $scale ), (int) ( $sel->y * $scale ), (int) ( $sel->w * $scale ), (int) ( $sel->h * $scale ) );
|
||||
} else {
|
||||
$scale = isset( $sel->r ) ? $sel->r : 1 / _image_get_preview_ratio( imagesx( $image ), imagesy( $image ) ); // Discard preview scaling.
|
||||
$image = _crop_image_resource( $image, $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale );
|
||||
|
@ -621,10 +621,10 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller {
|
||||
case 'crop':
|
||||
$size = $image_editor->get_size();
|
||||
|
||||
$crop_x = round( ( $size['width'] * $args['left'] ) / 100.0 );
|
||||
$crop_y = round( ( $size['height'] * $args['top'] ) / 100.0 );
|
||||
$width = round( ( $size['width'] * $args['width'] ) / 100.0 );
|
||||
$height = round( ( $size['height'] * $args['height'] ) / 100.0 );
|
||||
$crop_x = (int) round( ( $size['width'] * $args['left'] ) / 100.0 );
|
||||
$crop_y = (int) round( ( $size['height'] * $args['top'] ) / 100.0 );
|
||||
$width = (int) round( ( $size['width'] * $args['width'] ) / 100.0 );
|
||||
$height = (int) round( ( $size['height'] * $args['height'] ) / 100.0 );
|
||||
|
||||
if ( $size['width'] !== $width && $size['height'] !== $height ) {
|
||||
$result = $image_editor->crop( $crop_x, $crop_y, $width, $height );
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.6-beta3-58456';
|
||||
$wp_version = '6.6-beta3-58457';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user