I offer the following fix which ensures the Stock Avatar's width and height adhere to the defined maximum avatar limits whenever:
- a user edits their profile and selects a Stock Avatar, or
- an Admin/Mod edits a user's profile and selects a Stock Avatar.
While I have applied this fix to (my) version 7.5.3, it applies to 7.5.6 as well.
In
scripts/changebasic.inc.php find:
if ($picchange == "avatar") {
$Picture = $avurl;
$imagewidth = $avwidth;
$imageheight = $avheight;
}
and change to:
if ($picchange == "avatar") {
$Picture = $avurl;
$imagewidth = $avwidth;
$imageheight = $avheight;
if ($config['AVATAR_MAX_WIDTH'] && $config['AVATAR_MAX_HEIGHT']) {
if ($imagewidth > $config['AVATAR_MAX_WIDTH']) {
$div = $imagewidth / $config['AVATAR_MAX_WIDTH'];
$imagewidth = ceil($imagewidth / $div);
$imageheight = ceil($imageheight / $div);
}
if ($imageheight > $config['AVATAR_MAX_HEIGHT']) {
$div = $imageheight / $config['AVATAR_MAX_HEIGHT'];
$imageheight = ceil($imageheight / $div);
$imagewidth = ceil($imageheight / $div);
}
} }
In
admin/changeuser.php find:
if ($avatar == "stock") {
$picture = $avurl;
$imagewidth = $avwidth;
$imageheight = $avheight;
$picupdate = 1;
}
and change to:
if ($avatar == "stock") {
$picture = $avurl;
$imagewidth = $avwidth;
$imageheight = $avheight;
if ($config['AVATAR_MAX_WIDTH'] && $config['AVATAR_MAX_HEIGHT']) {
if ($imagewidth > $config['AVATAR_MAX_WIDTH']) {
$div = $imagewidth / $config['AVATAR_MAX_WIDTH'];
$imagewidth = ceil($imagewidth / $div);
$imageheight = ceil($imageheight / $div);
}
if ($imageheight > $config['AVATAR_MAX_HEIGHT']) {
$div = $imageheight / $config['AVATAR_MAX_HEIGHT'];
$imageheight = ceil($imageheight / $div);
$imagewidth = ceil($imageheight / $div);
}
} $picupdate = 1;
}
This has been
implemented and tested successfully on my forum as shown on the first page of the thread that contains a mix of stock and user uploaded avatars, all of which obey my 80x80 limit.