Skip to content

Commit 37df05c

Browse files
lineadepriestley
authored andcommitted
T1354 : Resize profile pics (specifically to handle github v3 api)
Reviewed by: epriestley GitHub Pull: phacility#140
1 parent e683236 commit 37df05c

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/applications/auth/controller/oauthregistration/PhabricatorOAuthDefaultRegistrationController.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,16 @@ public function processRequest() {
107107
'name' => $provider->getProviderKey().'-profile.jpg',
108108
'authorPHID' => $user->getPHID(),
109109
));
110-
$user->setProfileImagePHID($file->getPHID());
110+
$xformer = new PhabricatorImageTransformer();
111+
112+
// Resize OAuth image to a reasonable size
113+
$small_xformed = $xformer->executeProfileTransform(
114+
$file,
115+
$width = 50,
116+
$min_height = 50,
117+
$max_height = 50);
118+
119+
$user->setProfileImagePHID($small_xformed->getPHID());
111120
}
112121

113122
try {

src/applications/people/controller/settings/panels/PhabricatorUserOAuthSettingsPanelController.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,17 @@ private function refreshProfileImage(PhabricatorUserOAuthInfo $oauth_info) {
217217
'name' => $provider->getProviderKey().'-profile.jpg',
218218
'authorPHID' => $user->getPHID(),
219219
));
220-
$user->setProfileImagePHID($file->getPHID());
220+
221+
$xformer = new PhabricatorImageTransformer();
222+
223+
// Resize OAuth image to a reasonable size
224+
$small_xformed = $xformer->executeProfileTransform(
225+
$file,
226+
$width = 50,
227+
$min_height = 50,
228+
$max_height = 50);
229+
230+
$user->setProfileImagePHID($small_xformed->getPHID());
221231
$user->save();
222232
} else {
223233
$error = 'Unable to retrieve image.';

0 commit comments

Comments
 (0)