image_tag only retreiving the public_id of the images
Hi,
I am new to cloudinary. I try to have it work in RoR with carrierwave
I have set a public_id in my Uploader:
<code>
def public_id
dir_to_upload + Cloudinary::Utils.random_public_id + '.png'
end
private
def dir_to_upload
baserep = ''
if Rails.env.development? then
baserep = '/dev_' + Socket.gethostname
end
baserep + '/user_items/' + model.user_id.to_s + '/'
end
</code>
nothing fancy I just want to have the files stored in a specific folder.
In development when I run my debug, everithing works fine for the file upload, but when I user image_tag or cl_image_tag or cloudinary_url in my view, I only get the public_id and not the full url of the image on Cloudinary servers
ex:
/dev_vincent-VirtualBox/user_items/1/ygzsxqh5gl1mq1p1luhp.png
Am I missing something ?
-
Please note that:
- The public ID can't start with a slash (`/`).
- The public ID should exclude the extension part (e.g., `.png`).
Changing these two worked for me when trying it.
How do you perform the upload? Server side or client-side?
Can you share the cl_image_tag line of code you used? -
Hi
I finally found the problem by debugging the gem source code,
I was passing the url of the image as first parameter instead of sending directly the property of my object
ie cl_image_tag(o.image.url) where I should write cl_image_tag(o.image)
it worked then
thanks for the precisions about the public_id I did not found these specifications in the documentation
-
Thank you for the update, I'm glad it's working for you now :)
You can have a look at the following for more information regarding the convention of the public_id:
https://support.cloudinary.com/hc/en-us/articles/211665249-Legal-naming-conventions -
I am getting a
"oops
You're not authorized to access this page"
when I click on your link
https://support.cloudinary.com/hc/en-us/articles/211665249-Legal-naming-conventions
-
My apologies, here's the correct link:
https://support.cloudinary.com/hc/en-us/articles/115001317409--Legal-naming-conventions
Post is closed for comments.
Comments
5 comments