bengott/meteor-avatar — pull request #11 by steffenstraetz (2014-10-23 22:09:14+00:00)
Title: Added avatar initials as fallback

This PR adds the functionality to show an "initials avatar" as fallback when no "image avatar" could be loaded. The logic is that in case that an with an avatar cannot be loaded (404), the template will show the initials of the user instead. This means that the initials will only show if no defaultAvatarUrl or gravatarDefault has been set, or if the image is invalid / cannot be loaded for any reason and returns a 404.

The appearance of the initials are defined in the CSS and '"background" and "color" can be overridden in the template call if wanted:

{{> avatar user=currentUser class="circle small" background="#563d7c" color="#fff"}}

I have additionally added a "small" class in addition to the existing "large" class.

The getAvatar method tries to resolve the user´s initials from the profile field (tries combinations of firstName, lastName, familyName etc. if they exits), but can also be set directly in the template call like this:

{{> avatar user=currentUser initials="MA"}}