Avatar.php

Summary
Avatar.php
AvatarClass definition for user avatars
AvatarClass to hold the information about a user’s avatar(s)
schemaDefReturns the schema definition for this class
deleteDelete the current class’ avatar object.
deleteFromProfileDeletes all avatars (but may spare the original) from a profile.
byProfileGet an avatar by profile.
getUploadedGet the uploaded avatar for a user
getProfileAvatarsReturns all the available avatar files (of different sizes) for a user.
filenameConstructs the filename for this avatar
pathReturns the path to the avatar based on configuration variables.
urlReturns the url to this class instance’s avatar
displayUrlReturns the path to this class instance’s avatar (alias to url)
urlByProfileReturns the path to a given user’s avatar
defaultImageReturns the default avatar image (for situations a user doesn’t have a set avatar.)
newSizeCreate a new size of the user avatar using image resizing

Avatar

Class definition for user avatars

postActiv

the micro-blogging software

Copyright

Copyright © 2016-2017, Maiyannah Bishop

Derived from code copyright various sources

  • GNU Social © 2013-2016, Free Software Foundation, Inc
  • StatusNet © 2008-2012, StatusNet, Inc

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program.  If not, see http://www.gnu.org/licenses/.

https://www.gnu.org/licenses/agpl.html

About

Table Definition for avatar

PHP version

Tested with PHP 5.6

File Authors

Web

Avatar

Class to hold the information about a user’s avatar(s)

Summary
schemaDefReturns the schema definition for this class
deleteDelete the current class’ avatar object.
deleteFromProfileDeletes all avatars (but may spare the original) from a profile.
byProfileGet an avatar by profile.
getUploadedGet the uploaded avatar for a user
getProfileAvatarsReturns all the available avatar files (of different sizes) for a user.
filenameConstructs the filename for this avatar
pathReturns the path to the avatar based on configuration variables.
urlReturns the url to this class instance’s avatar
displayUrlReturns the path to this class instance’s avatar (alias to url)
urlByProfileReturns the path to a given user’s avatar
defaultImageReturns the default avatar image (for situations a user doesn’t have a set avatar.)
newSizeCreate a new size of the user avatar using image resizing

schemaDef

public static function schemaDef()

Returns the schema definition for this class

Returns

  • array

delete

function delete($useWhere = false)

Delete the current class’ avatar object.  We clean up the file, too.

Parameters

  • useWhere - default false

Returns

  • boolean success

deleteFromProfile

public static function deleteFromProfile(Profile $target,  
 $original = true)

Deletes all avatars (but may spare the original) from a profile.

Parameters

  • Profile $target - The profile we’re deleting avatars of.
  • boolean $original - Whether original should be removed or not.

Returns

  • Boolean success

byProfile

public static function byProfile(Profile $target,  
 $width = null,
 $height = null)

Get an avatar by profile.  Currently can’t call newSize with $height

Parameters

  • Profile target - user we’re fetching the avatar for
  • integer width - size of the avatar to get (default null)
  • integer height - size of the avatar to get (default null)

Returns

  • avatar object

Error state

  • If the avatar cannot be found, a NoAvatarException is thrown.

getUploaded

public static function getUploaded(Profile $target)

Get the uploaded avatar for a user

Parameters

  • Profile target - user we’re fetching the avatar for

Returns

  • avatar object

Error state

  • If the avatar cannot be found a NoAvatarException will be thrown

getProfileAvatars

public static function getProfileAvatars(Profile $target)

Returns all the available avatar files (of different sizes) for a user.

Parameters

  • Profile target - user we’re fetching avatars for

Returns

  • Array of avatar objects for the user

filename

static function filename($id,  
$extension,  
$size = null,
$extra = null)

Constructs the filename for this avatar

path

static function path($filename)

Returns the path to the avatar based on configuration variables.

Paramaters

  • filename - Filename for the avatar

Returns

  • string url

url

static function url($filename)

Returns the url to this class instance’s avatar

Parameters

  • filename - Filename for the avatar

Returns

  • string url

displayUrl

function displayUrl()

Returns the path to this class instance’s avatar (alias to url)

Return

  • string url

urlByProfile

static function urlByProfile(Profile $target,  
 $width = null,
 $height = null)

Returns the path to a given user’s avatar

Return

  • string URL to the given user’s avatar, or the default avatar if not set

defaultImage

static function defaultImage($size = null)

Returns the default avatar image (for situations a user doesn’t have a set avatar.)

Parameters

  • size - size to return the default avatar for

Returns

  • string path - path to the default avatar of the given size

newSize

static function newSize(Profile $target,
 $width)

Create a new size of the user avatar using image resizing

Parameters

  • Profile target - the user we’re creating a new avatar size for
  • integer width - new square size we’re creating the avatar for

Returns

  • object containing the new avatar

Error state

  • an exception will be thrown if an avatar is requested beyond the maxsize configuration attribute
public static function schemaDef()
Returns the schema definition for this class
function delete($useWhere = false)
Delete the current class’ avatar object.
public static function deleteFromProfile(Profile $target,  
 $original = true)
Deletes all avatars (but may spare the original) from a profile.
public static function byProfile(Profile $target,  
 $width = null,
 $height = null)
Get an avatar by profile.
public static function getUploaded(Profile $target)
Get the uploaded avatar for a user
public static function getProfileAvatars(Profile $target)
Returns all the available avatar files (of different sizes) for a user.
static function filename($id,  
$extension,  
$size = null,
$extra = null)
Constructs the filename for this avatar
static function path($filename)
Returns the path to the avatar based on configuration variables.
static function url($filename)
Returns the url to this class instance’s avatar
function displayUrl()
Returns the path to this class instance’s avatar (alias to url)
static function urlByProfile(Profile $target,  
 $width = null,
 $height = null)
Returns the path to a given user’s avatar
static function defaultImage($size = null)
Returns the default avatar image (for situations a user doesn’t have a set avatar.)
static function newSize(Profile $target,
 $width)
Create a new size of the user avatar using image resizing