Skip to content

Commit

Permalink
Fix for Auto Generated Avatar Image when Letters not Centered
Browse files Browse the repository at this point in the history
Issue is with older MS Edge browser. Now return png instead of svg. Once issue fixed by image provider should revert back to svg.

See: LasseRafn/ui-avatars#37 (comment)
  • Loading branch information
eSilverStrike committed Sep 7, 2020
1 parent 2313dd4 commit c9d8fa7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion system/lib-user.php
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,9 @@ function USER_generateUserICON($uid, $width = 0, $cssClasses = '', $anonName = '
$text_color = _textColorBasedOnBgColor($bg_color, 'FFFFFF', '000000');
// See https://ui-avatars.com/ for API
// See https://github.com/LasseRafn/php-initial-avatar-generator and https://github.com/LasseRafn/ui-avatars for github libraries
// Fix Letter offset issue for MS Edge 11. Specify png instead of default svg. See https://github.com/LasseRafn/ui-avatars/issues/37#issuecomment-688314690 (Note: Should set back to svg once issue fixed)
$extrasettings = PLG_getThemeItem('core-auto-generated-user-avatar-settings', 'core');
$retval = '<img src="https://ui-avatars.com/api/?name=' . $letters . '&color=' . $text_color . '&background=' . $bg_color . '&size=' . $_CONF['max_photo_width']
$retval = '<img src="https://ui-avatars.com/api/?name=' . $letters . '&color=' . $text_color . '&background=' . $bg_color . '&size=' . $_CONF['max_photo_width'] . '&format=png'
. $extrasettings . '" alt="" title="' . $altText . '" class="' . $cssClasses . '"';
if ($width > 0) {
// Since a square is returned set height as well
Expand Down

0 comments on commit c9d8fa7

Please sign in to comment.