diff --git a/src/applications/files/storage/file/PhabricatorFile.php b/src/applications/files/storage/file/PhabricatorFile.php index 3a7f92bf2f..20fb09c7e0 100644 --- a/src/applications/files/storage/file/PhabricatorFile.php +++ b/src/applications/files/storage/file/PhabricatorFile.php @@ -286,6 +286,24 @@ final class PhabricatorFile extends PhabricatorFileDAO { } } + public static function getTransformableImageFormats() { + $supported = array(); + + if (function_exists('imagejpeg')) { + $supported[] = 'jpg'; + } + + if (function_exists('imagepng')) { + $supported[] = 'png'; + } + + if (function_exists('imagegif')) { + $supported[] = 'gif'; + } + + return $supported; + } + protected function instantiateStorageEngine() { $engines = id(new PhutilSymbolLoader()) ->setType('class') diff --git a/src/applications/people/controller/settings/panels/profile/PhabricatorUserProfileSettingsPanelController.php b/src/applications/people/controller/settings/panels/profile/PhabricatorUserProfileSettingsPanelController.php index fedd49b405..41ef344a91 100644 --- a/src/applications/people/controller/settings/panels/profile/PhabricatorUserProfileSettingsPanelController.php +++ b/src/applications/people/controller/settings/panels/profile/PhabricatorUserProfileSettingsPanelController.php @@ -32,6 +32,9 @@ final class PhabricatorUserProfileSettingsPanelController $profile->setUserPHID($user->getPHID()); } + $supported_formats = PhabricatorFile::getTransformableImageFormats(); + + $e_image = null; $errors = array(); if ($request->isFormPost()) { $profile->setTitle($request->getStr('title')); @@ -65,9 +68,10 @@ final class PhabricatorUserProfileSettingsPanelController $max_height = 50); $user->setProfileImagePHID($small_xformed->getPHID()); } else { + $e_image = 'Not Supported'; $errors[] = - 'Only valid image files (jpg, jpeg, png or gif) '. - 'will be accepted.'; + 'This server only supports these image formats: '. + implode(', ', $supported_formats).'.'; } } } @@ -148,7 +152,9 @@ final class PhabricatorUserProfileSettingsPanelController ->appendChild( id(new AphrontFormFileControl()) ->setLabel('Change Image') - ->setName('image')) + ->setName('image') + ->setError($e_image) + ->setCaption('Supported formats: '.implode(', ', $supported_formats))) ->appendChild( id(new AphrontFormSubmitControl()) ->setValue('Save') diff --git a/src/applications/project/controller/profileedit/PhabricatorProjectProfileEditController.php b/src/applications/project/controller/profileedit/PhabricatorProjectProfileEditController.php index a30a74fe79..1f504557cf 100644 --- a/src/applications/project/controller/profileedit/PhabricatorProjectProfileEditController.php +++ b/src/applications/project/controller/profileedit/PhabricatorProjectProfileEditController.php @@ -52,7 +52,11 @@ final class PhabricatorProjectProfileEditController $affiliations = $project->loadAffiliations(); $affiliations = mpull($affiliations, null, 'getUserPHID'); + $supported_formats = PhabricatorFile::getTransformableImageFormats(); + $e_name = true; + $e_image = null; + $errors = array(); $state = null; if ($request->isFormPost()) { @@ -106,9 +110,10 @@ final class PhabricatorProjectProfileEditController $y = 50); $profile->setProfileImagePHID($xformed->getPHID()); } else { + $e_image = 'Not Supported'; $errors[] = - 'Only valid image files (jpg, jpeg, png or gif) '. - 'will be accepted.'; + 'This server only supports these image formats: '. + implode(', ', $supported_formats).'.'; } } } @@ -249,7 +254,9 @@ final class PhabricatorProjectProfileEditController ->appendChild( id(new AphrontFormFileControl()) ->setLabel('Change Image') - ->setName('image')) + ->setName('image') + ->setError($e_image) + ->setCaption('Supported formats: '.implode(', ', $supported_formats))) ->appendChild( '

Resources

'. ''.