Show:

Streams.Avatar Class

Constructs an avatar from fields, which are typically returned from the server.

Constructor

Streams.Avatar

(
  • fields
)

Parameters:

Item Index

Methods

Methods

byPrefix

(
  • prefix
  • callback
  • [options]
)
static

Get avatars by prefix

Parameters:

  • prefix String

    For example something the user started typing in an autocomplete field

  • callback Function

    If there were errors, first parameter is an array of errors otherwise, first parameter is null and second parameter is a hash of {userId: Streams.Avatar} pairs

  • [options] Object optional
    • [limit] Number optional

      for paging

    • [offset] Number optional

      for paging

    • [public=false] Boolean optional

      If true, also gets publicly accessible names.

displayName

(
  • [options]
  • [fallback='Someone']
)
String

Get the display name from a Streams.Avatar

Parameters:

  • [options] Object optional

    A bunch of options which can include:

    • [short] Boolean optional

      Show one part of the name only

    • [show] Boolean optional

      The parts of the name to show. Can have "f", "fu", "l", "lu", "flu" and "u" separated by spaces. The "fu" and "lu" represent firstname or lastname with fallback to username, while "flu" is "firstname lastname" with a fallback to username.

    • [html] Boolean optional

      If true, encloses the first name, last name, username in span tags. If an array, then it will be used as the attributes of the html.

    • [escape] Boolean optional

      If true, does HTML escaping of the retrieved fields

  • [fallback='Someone'] String optional

    What to return if there is no info to get displayName from.

Returns:

get

(
  • userId
  • callback
)
static

Avatar batch getter.

Parameters:

  • userId String | Object

    The id of the user whose avatar we are requesting. Alternatively, this can also be an object with keys "prefix", "limit", "offset"

  • callback Function

    if there were errors, first parameter is an array of errors otherwise, first parameter is null and second parameter is a Streams.Avatar object

(
  • [basename=40]
)
String

Get the url of the user icon from a Streams.Avatar

Parameters:

  • [basename=40] String | Number optional

    The last part after the slash, such as "50.png"

Returns:

String:

the url

Events

avatar.onError

Occurs when Avatar.get encounters an error loading an avatar from the server

byPrefix.onError

Occurs when Avatar.byPrefix encounters an error loading avatar from the server