Add UserAvatar::MIN_AVATAR_SIZE
authorMatthias Schmidt <gravatronics@live.com>
Wed, 18 Feb 2015 17:27:44 +0000 (18:27 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Wed, 18 Feb 2015 17:27:44 +0000 (18:27 +0100)
wcfsetup/install/files/lib/data/user/avatar/UserAvatar.class.php
wcfsetup/install/files/lib/system/upload/AvatarUploadFileValidationStrategy.class.php

index f6fc54dc575721039dd6bfd1de70c2c7bf073e9a..7feddf135a451298803c5352fb1b175eac9fe3bf 100644 (file)
@@ -37,6 +37,12 @@ class UserAvatar extends DatabaseObject implements IUserAvatar {
         */
        public static $maxThumbnailSize = 128;
        
+       /**
+        * minimum height and width of an uploaded avatar
+        * @var integer
+        */
+       const MIN_AVATAR_SIZE = 96;
+       
        /**
         * Returns the physical location of this avatar.
         * 
index 2afb9df4d4d027a140e62dfce8be4c2af75d61fb..b551ea441a67db5a06b0455022e89ae3a1d5fc02 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 namespace wcf\system\upload;
+use wcf\data\user\avatar\UserAvatar;
 use wcf\system\exception\SystemException;
 
 /**
@@ -19,10 +20,10 @@ class AvatarUploadFileValidationStrategy extends DefaultUploadFileValidationStra
        public function validate(UploadFile $uploadFile) {
                if (!parent::validate($uploadFile)) return false;
                
-               // get image size
+               // check image size
                try {
                        $imageData = getimagesize($uploadFile->getLocation());
-                       if ($imageData[0] < 96 || $imageData[1] < 96) {
+                       if ($imageData[0] < UserAvatar::MIN_AVATAR_SIZE || $imageData[1] < UserAvatar::MIN_AVATAR_SIZE) {
                                $uploadFile->setValidationErrorType('tooSmall');
                                return false;
                        }