How to render avatar images to .hbs template with user_id


(codechef) #1

I’m probably making this more difficult than it needs to be. I have a plug-in with a handlebars template. Within it, I have access to a list of objects that include a user_id. From that user_id, I’d like to render an avatar image. If needed, I could include the username, but still can’t figure out the correct way to accomplish this.

Ideally, I’d hope for something as simple as an img element with a src attribute of something like /avatar_img//<user_id>.png.

Note: I have found the {{avatar}} ember helper, but it seems to expect a full user object. Also, I’m a Discourse dev N00b so don’t rule out simple stuff.


(Rafael dos Santos Silva) #2

You won’t be able to render an avatar with only the user_id. You need the avatar_template attribute that is available on the user model.


(codechef) #3

Okay, I’ll pull it too. With that attribute, what’s the correct way to then display the avatar?