Robert Vogel has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/351615 )
Change subject: Avatars: Fix for image width
......................................................................
Avatars: Fix for image width
If user uploads own image to be profile image over Avatars dialog
image width (and possibly height) will be forced to be whatever is set as
default image width/height. This causes some images to lose their aspect
ratio.
I didnt want to change generateAvatar function to include width/height of
actual image in response, so i made the change on creating image element
itself. Because of possible unforseen consenquences, image width/height is
only changed if its smaller than the values in existing params, because in
that case it doesnt make sense to enlarge image beyond its actual size
Even if user uploads .jpg image as a profile picture, it will be converted
to .png
ERM: #6046
Needs cherry-picking to REL1_27 and REL1_23
Change-Id: I9ca3cf0cab3d38128bb56d47494e8407b1c99dbd
---
M Avatars/Avatars.class.php
1 file changed, 27 insertions(+), 2 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceExtensions
refs/changes/15/351615/1
diff --git a/Avatars/Avatars.class.php b/Avatars/Avatars.class.php
index 6c41486..f9ec958 100644
--- a/Avatars/Avatars.class.php
+++ b/Avatars/Avatars.class.php
@@ -116,7 +116,33 @@
}
# Set or generate user's avatar
$oUserMiniProfileView->setUserImageSrc($this->generateAvatar($oUser, $aParams));
+
+ $oFile = self::getAvatarFile( $oUser->getId() );
+
+ if( !$oFile || !$oFile->exists() ) {
+ return true;
+ }
+ if( $aParams['width'] > $oFile->getWidth() ) {
+ $aParams['width'] = $oFile->getWidth();
+ }
+
+ if( $aParams['height'] > $oFile->getHeight() ) {
+ $aParams['height'] = $oFile->getHeight();
+ }
+
+ $oUserMiniProfileView->setOptions( $aParams );
+
return true;
+ }
+
+ /**
+ * Gets Avatar file from user ID
+ * @param int $iUserId
+ * @return boolean|\File
+ */
+ public static function getAvatarFile( $iUserId ) {
+ $sAvatarFileName = self::$sAvatarFilePrefix . $iUserId . ".png";
+ return BsFileSystemHelper::getFileFromRepoName(
$sAvatarFileName, 'Avatars' );
}
/**
@@ -180,9 +206,8 @@
$sUserName = $oUser->getName();
$sUserRealName = $oUser->getRealName();
- $sAvatarFileName = self::$sAvatarFilePrefix . $iUserId . ".png";
# TODO: Check if this is more expensive than a simple
file_exists()
- $oFile =
BsFileSystemHelper::getFileFromRepoName($sAvatarFileName, 'Avatars');
+ $oFile = self::getAvatarFile( $iUserId );
// Prevent fatal when filerepo cannot be found.
if ( !$oFile ) {
--
To view, visit https://gerrit.wikimedia.org/r/351615
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9ca3cf0cab3d38128bb56d47494e8407b1c99dbd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: REL1_27
Gerrit-Owner: Robert Vogel <[email protected]>
Gerrit-Reviewer: ItSpiderman <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits