Problem/Motivation

After upgrading PHP 7.4 to 8.0, we get the following error:
TypeError: Unsupported operand types: int / string in Drupal\image_widget_crop\Element\ImageCrop::processCrop() (line 237 of /var/www/html/web/modules/contrib/image_widget_crop/src/Element/ImageCrop.php)

This is a result of division by empty String ($height or $height_ration)

Steps to reproduce

Go to Content -> Media -> Add Image, when you upload a new image, nothing would happen
In the logs, we find the following:
TypeError: Unsupported operand types: int / string in Drupal\image_widget_crop\Element\ImageCrop::processCrop() (line 237 of /var/www/html/web/modules/contrib/image_widget_crop/src/Element/ImageCrop.php)
#0 [internal function]: Drupal\image_widget_crop\Element\ImageCrop::processCrop(Array, Object(Drupal\Core\Form\FormState), Array)
#1 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(1007): call_user_func_array(Array, Array)
#2 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(1070): Drupal\Core\Form\FormBuilder->doBuildForm('media_image_add...', Array, Object(Drupal\Core\Form\FormState))

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

mustafa.hajmohammed created an issue.

baskaran’s picture

@mustafa.hajmohammed I am not able to reproduce this issue in 8.x-2.3 version. Either you upgrade the module to the 8.x-2.4 version or check if any patches applied.

ramu_bharu’s picture

Thanks @baskaran for your reply.

Yes, we used this patch for default crop functionality and it seems to be breaking.

Issue: https://www.drupal.org/project/image_widget_crop/issues/2865396

Mustafa, I tried the latest patch and it seems to be working fine. Thanks

mustafa.hajmohammed’s picture

Thank you @ramu_bharu, it worked!

mustafa.hajmohammed’s picture