cloudinary
cloudinary copied to clipboard
Not an issue, more a question!
Hi, love the package but i can't seem to understand the read and manipulation part. Right now i have it set up, it sends the image and triggers a method that alters the user() object and adds the response to the users profile. But i don't know how to use {{c.url}} and how to pass in the public_id etc. Right now i am simply setting the image src to url from the response on the user() object. The issue with this is that i have a square area but if someone uploads a portrait or landscape image it scales and stretches it but i need it to crop!
If you could give an example of using the c.url after and how you get the public_id.
ps I am using this as profile picture so it needs to stay the same image after one session etc. Thanks so much for your help in advanced! Ollie
I need help with that too < img src="{{c.url profile.avatar transformation="fit_100x150"}}" > Does not work...
Same here: img(src="#{c.url public_id format=format}", alt="sushi") is not working...
I have been able to get it work using an image tag that looks like so:
<img src="{{c.url publicId format=format gravity='faces' mode='thumb' crop='thumb' height=80 width=80}}" alt="profile image" class="image profile-image" />
and in the associated js file:
Template.uploader.helpers({
publicId:function(){
var u = Meteor.user();
if(u && u.profile && u.profile.profilePicture){
return u.profile.profilePicture.publicId;
}
},
format:function(){
var u = Meteor.user();
if(u && u.profile && u.profile.profilePicture){
return u.profile.profilePicture.format;
}
},
});
When I upload the image I update the user.profile object and save the publicId, format, and secure url in the user.profile.profilePicture object. If you look at the documentation here each option corresponds to an argument on the {{c.url }} template helper.
I hope that helps.
That massively helped, everything working now! Thank you so much!
How can I get the same exact function {{c.url publicId format=format gravity='faces' mode='thumb' crop='thumb' height=80 width=80}}
but on a template helper? like return c.url(publicId,{gravity:"faces",...})
Hi @shactdeveloper , you can use $.cloudinary.url()
on a helper instead. You can find more information on cloudinaryjs here.