Avatar: accept OC_Image as in setParameter

This commit is contained in:
Arthur Schiwon 2013-11-22 23:57:23 +01:00
parent 6fdce3b7e9
commit 6085878966
1 changed files with 7 additions and 3 deletions

View File

@ -44,15 +44,19 @@ class OC_Avatar implements \OCP\IAvatar {
/**
* @brief sets the users avatar
* @param $data mixed imagedata or path to set a new avatar
* @param $data mixed OC_Image, 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
* @return void
*/
public function set ($data) {
$img = new OC_Image($data);
if($data instanceOf OC_Image) {
$img = $data;
$data = $img->data();
} else {
$img = new OC_Image($data);
}
$type = substr($img->mimeType(), -3);
if ($type === 'peg') {
$type = 'jpg';