komentify / meteor-comments-ui

Simple templates for comment functionality in your Meteor App
MIT License
76 stars 40 forks source link

Custom avatars #92

Closed prathviraj080 closed 8 years ago

prathviraj080 commented 8 years ago

I've profile images for all the users and I'm storing it in Meteor.users collection. Is there any way I can display these URLs instead of default ones?

matteodem commented 8 years ago

Not sure why this is not implemented yet.

delay commented 8 years ago

The way I handled this since you can define a custom template for any part: I made a custom singleComment template. And altered the default template with this code.

{{> commentsBox id=post._id singleCommentTemplate="singleComment" }}

`

avatar
                </a>`

Then I created a helper. `Template.singleComment.helpers({

getAvatar: function() { 
    var user = Meteor.users.findOne(this.userId);
    var imageAvatar = Comments.ui.config().defaultAvatar;
    var customAvatar = user && user.profile && user.profile.customAvatar; //http://stackoverflow.com/questions/25758476/exception-in-template-helper-typeerror-cannot-read-property-profile-of-undef
    if (customAvatar === 1) {
        imageAvatar = "http://yourdomain.com/image/"+this.userId+".png";
    }
    return imageAvatar;
}

});`

There is probably a better way to do this but that's how I handled it.

matteodem commented 8 years ago

Yeah for now that's a solution that works, it'd be cool though to have something that's easily configurable.

prathviraj080 commented 8 years ago

+1 @delay

matteodem commented 8 years ago

This is possible now over the public API https://github.com/ARKHAM-Enterprises/meteor-comments-ui/blob/master/GUIDE.md#custom-avatars