HumHub Documentation (unofficial)

ProfileImage
in package

ProfileImage is responsible for all profile images.

This class handles all tasks related to profile images. Will used for Space or User Profiles.

Prefixes: "" = Resized profile image "_org" = Orginal uploaded file

Tags
since
0.5
author

Luke

Table of Contents

Properties

$container  : ContentContainerActiveRecord
$defaultImage  : string
$folder_images  : string
$guid  : string
$height  : int
$width  : int

Methods

__construct()  : mixed
Constructor of Profile Image
cropOriginal()  : bool
Crops the Original Image
delete()  : mixed
1 Deletes current profile
getAspectRatio()  : float
Get aspect ratio
getContainer()  : ContentContainerActiveRecord|string
getPath()  : string
Returns the Path of the Modified Profile Image
getUrl()  : string
Returns the URl of the Modified Profile Image
hasImage()  : bool
Indicates there is a custom profile image
height()  : int
Get height
render()  : string
Renders this profile image
setNew()  : mixed
Sets a new profile image by given temp file
width()  : int
Get width

Properties

$defaultImage

protected string $defaultImage

name of the default image

$folder_images

protected string $folder_images = 'profile_image'

folder name inside the uploads directory

$guid

protected string $guid = ''

is the guid of user or space

Methods

__construct()

Constructor of Profile Image

public __construct(string $guid[, string $defaultImage = 'default_user' ]) : mixed

UserId is optional, if not given the current user will used

Parameters
$guid : string
$defaultImage : string = 'default_user'

cropOriginal()

Crops the Original Image

public cropOriginal(int $x, int $y, int $h, int $w) : bool
Parameters
$x : int
$y : int
$h : int
$w : int
Tags
throws
Exception
Return values
bool

indicates the success

delete()

1 Deletes current profile

public delete() : mixed

getAspectRatio()

Get aspect ratio

public getAspectRatio() : float
Return values
float

getPath()

Returns the Path of the Modified Profile Image

public getPath([string $prefix = '' ]) : string
Parameters
$prefix : string = ''

for the profile image

Tags
throws
Exception
Return values
string

Path to the profile image

getUrl()

Returns the URl of the Modified Profile Image

public getUrl([string $prefix = '' ][, bool $scheme = false ]) : string
Parameters
$prefix : string = ''

Prefix of the returned image

$scheme : bool = false

URL Scheme

Tags
throws
InvalidConfigException
throws
Exception
Return values
string

Url of the profile image

hasImage()

Indicates there is a custom profile image

public hasImage() : bool
Tags
throws
Exception
Return values
bool

is there a profile image

height()

Get height

public height() : int
Return values
int

render()

Renders this profile image

public render([int $width = 32 ][, array<string|int, mixed> $cfg = [] ]) : string
Parameters
$width : int = 32
$cfg : array<string|int, mixed> = []
Tags
throws
IntegrityException
since
1.4
Return values
string

setNew()

Sets a new profile image by given temp file

public setNew(mixed $file) : mixed
Parameters
$file : mixed

CUploadedFile or file path

Tags
throws
Exception

width()

Get width

public width() : int
Return values
int

        
On this page

Search results