Nextcloud PHP API (stable18)

IAvatar

This class provides avatar functionality

Tags
since
6.0.0

Table of Contents

avatarBackgroundColor()  : Color
exists()  : bool
Check if an avatar exists for the user
get()  : bool|IImage
get the users avatar
getFile()  : File
Get the file of the avatar
isCustomAvatar()  : bool
Check if the avatar of a user is a custom uploaded one
remove()  : void
remove the users avatar
set()  : void
sets the users avatar
userChanged()  : mixed
Handle a changed user

Methods

avatarBackgroundColor()

public avatarBackgroundColor(string $text) : Color
Parameters
$text : string
Tags
since
14.0.0
Return values
Color

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

exists()

Check if an avatar exists for the user

public exists() : bool
Tags
since
8.1.0
Return values
bool

get()

get the users avatar

public get([int $size = 64 ]) : bool|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

Tags
since
6.0.0
  • size of -1 was added in 9.0.0
Return values
bool|IImage

containing the avatar or false if there's no image

getFile()

Get the file of the avatar

public getFile(int $size) : File
Parameters
$size : int

-1 can be used to not scale the image

Tags
throws
NotFoundException
since
9.0.0
Return values
File

isCustomAvatar()

Check if the avatar of a user is a custom uploaded one

public isCustomAvatar() : bool
Tags
since
14.0.0
Return values
bool

remove()

remove the users avatar

public remove() : void
Tags
since
6.0.0

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
throws
Exception

if the provided file is not a jpg or png image

throws
Exception

if the provided image is not valid

throws
NotSquareException

if the image is not square

since
6.0.0

userChanged()

Handle a changed user

public userChanged(mixed $feature, mixed $oldValue, mixed $newValue) : mixed
Parameters
$feature : mixed
$oldValue : mixed
$newValue : mixed
Tags
since
13.0.0
Return values
mixed

Search results