How does discourse generate its default avatars?

I’m looking into different options for generating unique avatars, and I’m curious as to how discourse generates the letter avatars.

1 Like

Most of the magic happens in this file:

Awesome, I think I’m getting the gist of it. The one big question I have is what happens with this call I’m not terribly familiar with Ruby, so if you could dumb it down a bit.

%w{} becomes an array of strings, and the join method is called to convert it to a space separated string. These instructions are wrapped in backticks. The convert application is called with the arguments from the instructions array. Remember that "#{object}" is an in-string replacement; where the object in question will be converted to a string.

convert is documented here: ImageMagick - Command-line Tools: Convert

It’s a native program and part of the ImageMagick set of image manipulation tools. IM gets installed by the Ubuntu package manager inside the docker container; it’s not part of Discourse.

@trident @elberet awesome thanks guys!

I was about to post this question in meta, before I found this thread:

I’m wondering if there’s a way to upload a handful of default profile images and have the system automatically, randomly select one of the profile pictures, and apply it to each new users as they join the community. Then, if the users want to change, they can, but this way you get a variety of profile images.

I ended up finding my answer to this question over here, and was so excited to see that Discourse has perfectly executed this feature!

I just wanted to close this loop in case anyone, like me, was looking at being able to create a set of new default avatars that are auto applied to new users who don’t take the time to add a profile picture or avatar. I feel like this is a MUST for online community platforms.

This auto-assignment of avatars from a pool of pre-created images was a feature in Jive-x, but not in another community platform I used, called Telligent. I had to pay someone to develop this feature for Telligent. It’s also not a feature in Higher Logic, a platform I’ve been building on, most recently.

Here is my standard use case for this feature
When new users join a community, they often do not customize their profile picture. I’ve developed several communities and evaluated hundreds of sample online communities and have found this to be true across the board. So when these people participate in forums, and they all have the same generic profile images, it looks like the same person is responding. Doesn’t really feel active or alive. But if each new person is auto (randomly) assigned a profile image from a preset pool of images, then when those folks post, the community looks much more friendly and welcoming.

e.g. you can see how this was implemented in the Bridge Community I built for Instructure. Notice that each new users a nice branded avatar, and as I’ve observed… most don’t add a personal pic. (fwiw the community at present has changed a bit since it’s original design :smirk: )