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

Croppable undermining dimension rules #107

Open JeroenHauser opened 1 year ago

JeroenHauser commented 1 year ago

Hi! First of all, thanks for creating this package. It's very helpful on a project I'm working on 🙂

Unfortunately, the croppable() option is undermining the Nova dimension rules.

AdvancedImage::make('image_path') ->hideFromIndex() ->rules('image', 'dimensions:min_width=1000') ->croppable() ->resize(1000)

Now, I can upload an image with an original width of 2000px. Then I make the croppable box very, very small. When I save it, the saved image has only a width of 150px. This is understandable: the Nova rules check the dimensions on the uploaded image, not the end result after cropping and resizing. Also the resize() option doesn't make the end result viable, since by default it's instructed not to upsize.

What would be really great, is when the minWidth options of cropperjs would also be set whenever a resize() value is set. Users then cannot make the cropper smaller than the minimum dimensions.

I'm sorry I cannot contribute to the package myself. I only started developing Laravel 9 months ago. Packages and Nova are still a little bit magic to me. I looked at the code, but I also see that it requires changes to the Vue files. My Vue experience level is zero, unfortunately. I'll be patiently waiting for this improvement, hope it ends up on the backlog!