Hack the algorithm that generates the default profile picture/avatar

Hi everyone,

I would like to customize the algorithm which defines how the automatic generation of the default profile pictures (or avatars), especially the characters, works.

As of right now (using Nextcloud 27.1.4) every user who has not uploaded a profile picture, the first letters of the display name will be used and shown. So for Jane Doe it will be JD. For most use cases this is fine, but when using Jane (Doe) as a display name J( is being shown.

It would be great to be able to set to generate JD either way, for example by having a whole new field which accepts just two characters and using this extra input to generate the profile picture or by being able to define “use the first/nth/last character of the first word in the display name [and if there is a second word use the first/nth/last character of the second word in the display name]”.

I am more of a sysadmin than a programmer, so before adding a feature request I may being able to help myself quickly and playfully with adapting - because hey, Nextcloud is great FLOSS.

Thank you for any input on this.

Hey, take a look at the following code to get a starting point: server/lib/private/Avatar/Avatar.php at 656d3a4d825a9227a8c8ae87bd19669ce9c892fc · nextcloud/server · GitHub

Pull requests are always welcome :wink:

1 Like