PlaceholderAvatar

class OC\Avatar\PlaceholderAvatar
This class represents a registered user’s placeholder avatar.
It generates an image based on the user’s initials and caches it on storage
for faster retrieval, unlike the GuestAvatar.
Source:lib/private/Avatar/PlaceholderAvatar.php#49
Parent:OC\Avatar\Avatar

Properties

Methods

public OC\Avatar\PlaceholderAvatar::__construct($folder, $user, $logger)
UserAvatar constructor.
Source:

lib/private/Avatar/PlaceholderAvatar.php#65

Parameters:
public OC\Avatar\PlaceholderAvatar::exists()
Check if an avatar exists for the user
Source:lib/private/Avatar/PlaceholderAvatar.php#80
Returns:bool
public OC\Avatar\PlaceholderAvatar::set($data)
Sets the users avatar.
Source:

lib/private/Avatar/PlaceholderAvatar.php#93

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

public OC\Avatar\PlaceholderAvatar::remove($silent=false)
Removes the users avatar.
Source:lib/private/Avatar/PlaceholderAvatar.php#100
public OC\Avatar\PlaceholderAvatar::getFile($size)
Returns the avatar for an user.
If there is no avatar file yet, one is generated.
Source:

lib/private/Avatar/PlaceholderAvatar.php#119

Parameters:
  • $size (int)
Returns:

\OCP\Files\SimpleFS\ISimpleFile

Throws:

\OCP\Files\NotFoundException

Throws:

\OCP\Files\NotPermittedException

Throws:

\OCP\PreConditionNotMetException

Throws:

\OCP\Files\NotFoundException

Throws:

\OCP\Files\NotPermittedException

Throws:

\OCP\PreConditionNotMetException

Throws:

\OCP\Files\NotFoundException

Throws:

\OCP\Files\NotPermittedException

Throws:

\OCP\PreConditionNotMetException

public OC\Avatar\PlaceholderAvatar::getDisplayName()
Returns the user display name.
Source:lib/private/Avatar/PlaceholderAvatar.php#158
Returns:string
public OC\Avatar\PlaceholderAvatar::userChanged($feature, $oldValue, $newValue)
Handles user changes.
Source:

lib/private/Avatar/PlaceholderAvatar.php#171

Parameters:
  • $feature (string) The changed feature
  • $oldValue (mixed) The previous value
  • $newValue (mixed) The new value
Throws:

\OCP\Files\NotPermittedException

Throws:

\OCP\PreConditionNotMetException

Throws:

\OCP\Files\NotPermittedException

Throws:

\OCP\PreConditionNotMetException

public OC\Avatar\PlaceholderAvatar::isCustomAvatar()
Check if the avatar of a user is a custom uploaded one
Source:lib/private/Avatar/PlaceholderAvatar.php#180
Returns:bool