IAvatar

interface OCP\IAvatar
This class provides avatar functionality
Implemented by:OC\Avatar\Avatar
Source:lib/public/IAvatar.php#37

Methods

public OCP\IAvatar::get($size=64)
get the users avatar
Source:

lib/public/IAvatar.php#45

Parameters:
  • $size (int) size in px of the avatar, avatars are square, defaults to 64, -1 can be used to not scale the image
Returns:

bool | \OCP\IImage containing the avatar or false if there’s no image

Since:

6.0.0 - size of -1 was added in 9.0.0

public OCP\IAvatar::exists()
Check if an avatar exists for the user
Source:lib/public/IAvatar.php#53
Returns:bool
Since:8.1.0
public OCP\IAvatar::isCustomAvatar()
Check if the avatar of a user is a custom uploaded one
Source:lib/public/IAvatar.php#61
Returns:bool
Since:14.0.0
public OCP\IAvatar::set($data)
sets the users avatar
Source:

lib/public/IAvatar.php#72

Parameters:
  • $data (OCP\IImage | resource | string) An image object, imagedata or path to set a new avatar
Throws:

\Exception if the provided file is not a jpg or png image

Throws:

\Exception if the provided image is not valid

Throws:

\OC\NotSquareException if the image is not square

Throws:

\Exception if the provided file is not a jpg or png image

Throws:

\Exception if the provided image is not valid

Throws:

\OC\NotSquareException if the image is not square

Throws:

\Exception if the provided file is not a jpg or png image

Throws:

\Exception if the provided image is not valid

Throws:

\OC\NotSquareException if the image is not square

Returns:

void

Since:

6.0.0

public OCP\IAvatar::remove()
remove the users avatar
Source:lib/public/IAvatar.php#79
Returns:void
Since:6.0.0
public OCP\IAvatar::getFile($size)
Get the file of the avatar
Source:

lib/public/IAvatar.php#88

Parameters:
  • $size (int) -1 can be used to not scale the image
Returns:

\OCP\Files\File

Throws:

\OCP\Files\NotFoundException

Since:

9.0.0

public OCP\IAvatar::avatarBackgroundColor($text)
Source:

lib/public/IAvatar.php#95

Parameters:
  • $text (string)
Returns:

\OCP\Color Object containting r g b int in the range [0, 255]

Since:

14.0.0

public OCP\IAvatar::userChanged($feature, $oldValue, $newValue)
Handle a changed user
Source:lib/public/IAvatar.php#101
Since:13.0.0