How can I use Cloudinary to output a url with transformation as a string?

旧城冷巷雨未停 提交于 2019-12-05 16:04:55

You can use the cloudinary_url helper to generate the URL without the image tag. For example:

cloudinary_url(image.asset.filename.to_s, transformation: "medium")

As zeantsoi said, if you are using CarrierWave, you can also pass the uploader itself as a parameter:

cloudinary_url(image.asset, transformation: "medium")

On top of Tal Lev-Ami's answer:

If you need to call cloudinary_url outside of a view (for instance in a serializer model for an api), you have 2 options:

  • rely on "helper": helper.cloudinary_url
  • or use Cloudinary::Utils.cloudinary_url
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!