简体   繁体   中英

How generate a cloudinary URL from the rails controller

I'm Using rails and the cloudinary's gem with carrierwave. I would like make a URL from the controller:

url = myModel.url_field
options = { width: 200 }
Cloudinary::Utils.cloudinary_url(url, options)

But I only get the URL without the crop options

(The urls are only examples)

http://res.cloudinary.com/cloud/image/upload/v1458860591/logos/20160324170310.jpg

There is one way to get the url? like:

http://res.cloudinary.com/cloud/image/upload/ w_200 /v1458860591/logos/20160324170310.jpg

After some more searching I found an answer that's working for me in python, the same should work for the ruby version.

Basically, don't pass the width inside the options, place it directly:

Cloudinary::Utils.cloudinary_url(url, width=200)

This should give you the url with the width in it :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM