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'];
|
$h = $size['height'];
|
||||||
|
|
||||||
$scale = isset( $sel->r ) ? $sel->r : 1 / _image_get_preview_ratio( $w, $h ); // Discard preview scaling.
|
$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 {
|
} else {
|
||||||
$scale = isset( $sel->r ) ? $sel->r : 1 / _image_get_preview_ratio( imagesx( $image ), imagesy( $image ) ); // Discard preview scaling.
|
$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 );
|
$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':
|
case 'crop':
|
||||||
$size = $image_editor->get_size();
|
$size = $image_editor->get_size();
|
||||||
|
|
||||||
$crop_x = round( ( $size['width'] * $args['left'] ) / 100.0 );
|
$crop_x = (int) round( ( $size['width'] * $args['left'] ) / 100.0 );
|
||||||
$crop_y = round( ( $size['height'] * $args['top'] ) / 100.0 );
|
$crop_y = (int) round( ( $size['height'] * $args['top'] ) / 100.0 );
|
||||||
$width = round( ( $size['width'] * $args['width'] ) / 100.0 );
|
$width = (int) round( ( $size['width'] * $args['width'] ) / 100.0 );
|
||||||
$height = round( ( $size['height'] * $args['height'] ) / 100.0 );
|
$height = (int) round( ( $size['height'] * $args['height'] ) / 100.0 );
|
||||||
|
|
||||||
if ( $size['width'] !== $width && $size['height'] !== $height ) {
|
if ( $size['width'] !== $width && $size['height'] !== $height ) {
|
||||||
$result = $image_editor->crop( $crop_x, $crop_y, $width, $height );
|
$result = $image_editor->crop( $crop_x, $crop_y, $width, $height );
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue