diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-01-25 19:54:15 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-01-25 19:54:15 +0100 |
commit | fe08700b597b8c765716e92569d30524cfef9b84 (patch) | |
tree | 0fed484b8ae9a7e331e9686011869ebb4650445b /lib | |
parent | a4ea3563e7f95685869d812cc969baadaeb91b1f (diff) | |
parent | 728caf13f8656fa12253dd512a1fa49897a0566f (diff) | |
download | nextcloud-server-fe08700b597b8c765716e92569d30524cfef9b84.tar.gz nextcloud-server-fe08700b597b8c765716e92569d30524cfef9b84.zip |
Merge pull request #21885 from owncloud/add-size-minus-zero-to-avatar
Adding support of -1 as size to be passed into get and getFile
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/avatar.php | 22 | ||||
-rw-r--r-- | lib/public/iavatar.php | 6 |
2 files changed, 14 insertions, 14 deletions
diff --git a/lib/private/avatar.php b/lib/private/avatar.php index d4e5f5225dc..a276fb7ccf9 100644 --- a/lib/private/avatar.php +++ b/lib/private/avatar.php @@ -58,10 +58,8 @@ class Avatar implements \OCP\IAvatar { } /** - * get the users avatar - * @param int $size size in px of the avatar, avatars are square, defaults to 64 - * @return boolean|\OCP\IImage containing the avatar or false if there's no image - */ + * @inheritdoc + */ public function get ($size = 64) { try { $file = $this->getFile($size); @@ -135,16 +133,16 @@ class Avatar implements \OCP\IAvatar { } /** - * Get the File of an avatar of size $size. - * - * @param int $size - * @return File - * @throws NotFoundException + * @inheritdoc */ public function getFile($size) { $ext = $this->getExtention(); - $path = 'avatar.' . $size . '.' . $ext; + if ($size === -1) { + $path = 'avatar.' . $ext; + } else { + $path = 'avatar.' . $size . '.' . $ext; + } try { $file = $this->folder->get($path); @@ -157,7 +155,9 @@ class Avatar implements \OCP\IAvatar { /** @var File $file */ $file = $this->folder->get('avatar.' . $ext); $avatar->loadFromData($file->getContent()); - $avatar->resize($size); + if ($size !== -1) { + $avatar->resize($size); + } $file = $this->folder->newFile($path); $file->putContent($avatar->data()); } diff --git a/lib/public/iavatar.php b/lib/public/iavatar.php index fc4058ab4f2..6203d3d5576 100644 --- a/lib/public/iavatar.php +++ b/lib/public/iavatar.php @@ -36,9 +36,9 @@ interface IAvatar { /** * get the users avatar - * @param int $size size in px of the avatar, avatars are square, defaults to 64 + * @param int $size size in px of the avatar, avatars are square, defaults to 64, -1 can be used to not scale the image * @return boolean|\OCP\IImage containing the avatar or false if there's no image - * @since 6.0.0 + * @since 6.0.0 - size of -1 was added in 9.0.0 */ public function get($size = 64); @@ -70,7 +70,7 @@ interface IAvatar { /** * Get the file of the avatar - * @param int $size + * @param int $size -1 can be used to not scale the image * @return File * @throws NotFoundException * @since 9.0.0 |