Make WordPress Core


Ignore:
Timestamp:
06/21/2024 08:35:25 PM (8 months ago)
Author:
joedolson
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

    r58447 r58457  
    622622                    $size = $image_editor->get_size();
    623623
    624                     $crop_x = round( ( $size['width'] * $args['left'] ) / 100.0 );
    625                     $crop_y = round( ( $size['height'] * $args['top'] ) / 100.0 );
    626                     $width  = round( ( $size['width'] * $args['width'] ) / 100.0 );
    627                     $height = round( ( $size['height'] * $args['height'] ) / 100.0 );
     624                    $crop_x = (int) round( ( $size['width'] * $args['left'] ) / 100.0 );
     625                    $crop_y = (int) round( ( $size['height'] * $args['top'] ) / 100.0 );
     626                    $width  = (int) round( ( $size['width'] * $args['width'] ) / 100.0 );
     627                    $height = (int) round( ( $size['height'] * $args['height'] ) / 100.0 );
    628628
    629629                    if ( $size['width'] !== $width && $size['height'] !== $height ) {
Note: See TracChangeset for help on using the changeset viewer.