ctessier / nova-advanced-image-field

🌄 📐 A Laravel Nova advanced image field with cropping and resizing using Vue Advanced Cropper and Intervention Image
https://novapackages.com/packages/ctessier/nova-advanced-image-field
MIT License
100 stars 26 forks source link

[BUGFIX] Prevent float values from going into the crop function #86

Closed Woeler closed 1 year ago

Woeler commented 1 year ago

We ran into the issue that float values were passed to the crop function. This resulted in an error, as the crop function only wants integers. This PR fixes that. Below you can see the logged $cropperData that was passed into the cropImage function on our live environment.

{
    "data": {
        "stdClass": {
            "width": 2012,
            "height": 1132,
            "left": 128,
            "top": 119.01869791425563
        }
    }
}

Error

crop() accepts only integer values as argument 4. {"userId":2,"exception":"[object] (Intervention\\Image\\Exception\\InvalidArgumentException(code: 0): crop() accepts only integer values as argument 4. at /home/user/domain.com/vendor/intervention/image/src/Intervention/Image/Commands/Argument.php:138) 
sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

ctessier commented 1 year ago

Thank you for the contribution @Woeler! And for your support for this package :pray: !

Do you have step to reproduce maybe? I'll have a look asap.

Thank you

Woeler commented 1 year ago

Unfortunately I cannot reproduce it locally. One of our editors ran into the issue with a particular file on our live environment. I can reproduce the issue on the live environment with that particular file. But otherwise I cannot reproduce it, not even locally with the same file. It is very odd. However, the error does occur for some reason, so I suppose in time, it will occur for other users as well. The reasons for the error are beyond me though to be honest.

ctessier commented 1 year ago

Pull request released in v2.0.2