I am using cloudinary to store user avatars in my rails 4 application. I also have a placeholder image in my image assets. I wanted to know that if a user hasnt uploaded his avatar, how do i load it from the localhost.
As of now i have to add checks as
- if user.avatar.present?
= cl_image_tag(user.avatar.filename, width: 46, height: 46)
- else
= image_tag 'default.png', style: 'width:46px; height:46px;'
i can specify a default image as
= cl_image_tag(user.avatar.filename, width: 46, height: 46, default: 'default.png')
but the default image has to be stored on cloudinary. I dont want to store it on cloudinary since cloudinary charges for data transfer. hence, i have stored 'default.png' is stored in assets. 'cl_image_tag' is a helper provided by cloudinary to load images from there.
assets/images
folder. – Sampat Badhe