IAvatar

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

Methods

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

lib/public/IAvatar.php#46

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#54
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#62
Returns:bool
Since:14.0.0
public OCP\IAvatar::set($data)
sets the users avatar
Source:

lib/public/IAvatar.php#73

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#80
Returns:void
Since:6.0.0
public OCP\IAvatar::getFile($size)
Get the file of the avatar
Source:

lib/public/IAvatar.php#89

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#96

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#102
Since:13.0.0