Lepozepo / cloudinary

MIT License
94 stars 42 forks source link

Not an issue, more a question! #36

Open ghost opened 9 years ago

ghost commented 9 years ago

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

rafaelcorreiapoli commented 9 years ago

I need help with that too < img src="{{c.url profile.avatar transformation="fit_100x150"}}" > Does not work...

moise-g commented 9 years ago

Same here: img(src="#{c.url public_id format=format}", alt="sushi") is not working...

rfines commented 9 years ago

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.

ghost commented 9 years ago

That massively helped, everything working now! Thank you so much!

rafaelcorreiapoli commented 9 years ago

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",...})

Lepozepo commented 9 years ago

Hi @shactdeveloper , you can use $.cloudinary.url() on a helper instead. You can find more information on cloudinaryjs here.