Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Cloudinary image URL

I have a model called Tile, and it has attachment: has_attachment :image_attachment

I can use cl_image_tag @tile.image_attachment.path to display img tag but I want to get only full URL to embed is an background image in inline style, is there a way to get full URL?

``@tile.image_attachment.path returns v1458814322/bgo1zuv4kji17f58x5m5.jpg

like image 715
szromek Avatar asked Mar 24 '16 13:03

szromek


2 Answers

You just need to use cl_image_path(@tile.image_attachment)

like image 75
rlarcombe Avatar answered Sep 27 '22 23:09

rlarcombe


If you want to access the URL somewhere else than in a view file:

options = {width: 50, height: 50, crop: :fill}
Cloudinary::Utils.cloudinary_url(image_id, options)
like image 34
Fellow Stranger Avatar answered Sep 27 '22 23:09

Fellow Stranger