cloudinary / cloudinary_gem

Cloudinary GEM for Ruby on Rails integration
https://cloudinary.com
419 stars 284 forks source link

Absence of :crop silently ignores :width and :height #202

Closed janko closed 2 years ago

janko commented 8 years ago

Thank you for an awesome service and a nice wrapper gem.

While playing with URLs I noticed that if I don't pass in :crop, the :width and :height options will be ignored. That surprised me, because I didn't know that :crop was mandatory, I only realized it through some source code diving.

My proposal is to instead make :crop default to "fit", or whatever value you find to be a good default. It could be on the gem level or Cloudinary level, I don't know which one is better.

If the :crop option really must be mandatory, it would be good to at least add a warning when :crop is not passed in that :width and :height will be ignored.

roeeba commented 8 years ago

Hi @janko-m , thank you very much for the interesting suggestion. We have added this to our road-map. We will update on the ETA once this is determined. Thanks again!

Frexuz commented 7 years ago

Cool, exactly what I had an issue with! Thanks @janko-m :)

aleksandar-cloudinary commented 2 years ago

Hi @janko, @Frexuz - I saw this thread was open for a while so I'm revisiting it. When using resizing transformations in URLs, such as width and/or height, you can use those without a crop mode and it will default to scale on the backend. That said, via the SDKs, crop mode is a mandatory parameter otherwise the resizing parameters like width/height won't be set as you've seen. This is documented under the Note section just below this section of the documentation - https://cloudinary.com/documentation/resizing_and_cropping#resize_and_crop_modes. At the moment, there aren't any plans to change this behaviour, so I'll close this thread, however, if that changes we will be sure to update it here too. 🙏