cloudinary icon indicating copy to clipboard operation
cloudinary copied to clipboard

Not an issue, more a question!

Open ghost opened this issue 9 years ago • 6 comments

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

ghost avatar Aug 06 '15 22:08 ghost

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

rafaelcorreiapoli avatar Aug 07 '15 02:08 rafaelcorreiapoli

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

moise-g avatar Aug 07 '15 17:08 moise-g

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.

rfines avatar Aug 07 '15 18:08 rfines

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

ghost avatar Aug 07 '15 20:08 ghost

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

rafaelcorreiapoli avatar Aug 17 '15 03:08 rafaelcorreiapoli

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

Lepozepo avatar Aug 18 '15 04:08 Lepozepo