From 37df05c7a5803cfb70944b5e1b1ba28c82adb091 Mon Sep 17 00:00:00 2001 From: Daniel Fullarton Date: Mon, 25 Jun 2012 21:25:50 +1000 Subject: [PATCH] T1354 : Resize profile pics (specifically to handle github v3 api) Reviewed by: epriestley GitHub Pull: https://github.com/facebook/phabricator/pull/140 --- ...PhabricatorOAuthDefaultRegistrationController.php | 11 ++++++++++- .../PhabricatorUserOAuthSettingsPanelController.php | 12 +++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/applications/auth/controller/oauthregistration/PhabricatorOAuthDefaultRegistrationController.php b/src/applications/auth/controller/oauthregistration/PhabricatorOAuthDefaultRegistrationController.php index 9c8c157690..3f3c114d9d 100644 --- a/src/applications/auth/controller/oauthregistration/PhabricatorOAuthDefaultRegistrationController.php +++ b/src/applications/auth/controller/oauthregistration/PhabricatorOAuthDefaultRegistrationController.php @@ -107,7 +107,16 @@ final class PhabricatorOAuthDefaultRegistrationController 'name' => $provider->getProviderKey().'-profile.jpg', 'authorPHID' => $user->getPHID(), )); - $user->setProfileImagePHID($file->getPHID()); + $xformer = new PhabricatorImageTransformer(); + + // Resize OAuth image to a reasonable size + $small_xformed = $xformer->executeProfileTransform( + $file, + $width = 50, + $min_height = 50, + $max_height = 50); + + $user->setProfileImagePHID($small_xformed->getPHID()); } try { diff --git a/src/applications/people/controller/settings/panels/PhabricatorUserOAuthSettingsPanelController.php b/src/applications/people/controller/settings/panels/PhabricatorUserOAuthSettingsPanelController.php index 8f8dbf8fd4..031112b9cd 100644 --- a/src/applications/people/controller/settings/panels/PhabricatorUserOAuthSettingsPanelController.php +++ b/src/applications/people/controller/settings/panels/PhabricatorUserOAuthSettingsPanelController.php @@ -217,7 +217,17 @@ final class PhabricatorUserOAuthSettingsPanelController 'name' => $provider->getProviderKey().'-profile.jpg', 'authorPHID' => $user->getPHID(), )); - $user->setProfileImagePHID($file->getPHID()); + + $xformer = new PhabricatorImageTransformer(); + + // Resize OAuth image to a reasonable size + $small_xformed = $xformer->executeProfileTransform( + $file, + $width = 50, + $min_height = 50, + $max_height = 50); + + $user->setProfileImagePHID($small_xformed->getPHID()); $user->save(); } else { $error = 'Unable to retrieve image.';