IAvatar
in
This class provides avatar functionality
Tags
Table of Contents
Methods
- avatarBackgroundColor() : Color
- Get the avatar background color
- exists() : bool
- Check if an avatar exists for the user
- get() : false|IImage
- Get the users avatar
- getFile() : ISimpleFile
- Get the file of the avatar
- isCustomAvatar() : bool
- Check if the avatar of a user is a custom uploaded one
- remove() : void
- Remove the user's avatar
- set() : void
- Sets the users avatar
- userChanged() : void
- Updates the display name if changed.
Methods
avatarBackgroundColor()
Get the avatar background color
public
avatarBackgroundColor(string $hash) : Color
Parameters
- $hash : string
Tags
Return values
Colorexists()
Check if an avatar exists for the user
public
exists() : bool
Tags
Return values
boolget()
Get the users avatar
public
get([int $size = 64 ][, bool $darkTheme = false ]) : false|IImage
Parameters
- $size : int = 64
-
size in px of the avatar, avatars are square, defaults to 64, -1 can be used to not scale the image
- $darkTheme : bool = false
-
Should the generated avatar be dark themed
Tags
Return values
false|IImage —containing the avatar or false if there's no image
getFile()
Get the file of the avatar
public
getFile(int $size[, bool $darkTheme = false ]) : ISimpleFile
Parameters
- $size : int
-
The desired image size. -1 can be used to not scale the image
- $darkTheme : bool = false
-
Should the generated avatar be dark themed
Tags
Return values
ISimpleFileisCustomAvatar()
Check if the avatar of a user is a custom uploaded one
public
isCustomAvatar() : bool
Tags
Return values
boolremove()
Remove the user's avatar
public
remove([bool $silent = false ]) : void
Parameters
- $silent : bool = false
-
Whether removing the avatar should trigger a change
Tags
set()
Sets the users avatar
public
set(IImage|resource|string $data) : void
Parameters
- $data : IImage|resource|string
-
An image object, imagedata or path to set a new avatar
Tags
userChanged()
Updates the display name if changed.
public
userChanged(string $feature, mixed $oldValue, mixed $newValue) : void
Parameters
- $feature : string
-
The changed feature
- $oldValue : mixed
-
The previous value
- $newValue : mixed
-
The new value