Previous Thread
Next Thread
Print Thread
Hop To
Joined: Jul 2006
Posts: 116
M
member
member
M Offline
Joined: Jul 2006
Posts: 116
If I have avatar display resolutions limited to 80x80 (Profile Settings > Avatars), but I upload stock avatars which happen to be 120x120 in size, if my users select one of these new stock avatars, then it gets displayed at 120x120 and not the 80x80 limit I've set.

Is this a bug, or was it intended to be this way?

Personally, I'm not fond of having to resize stock avatar images just for the purpose of uploading. It's also a pain if I later decide to increase the resolution.

Joined: Jul 2006
Posts: 116
M
member
member
M Offline
Joined: Jul 2006
Posts: 116
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:

PHP Code

	// -------------------------------------------------------
	// If we are using an avatar then we set the stuff up here
	if ($picchange == "avatar") {
		$Picture = $avurl;
		$imagewidth = $avwidth;
		$imageheight = $avheight;
	}
 

and change to:

PHP Code

	// -------------------------------------------------------
	// If we are using an avatar then we set the stuff up here
	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);
			}
		} // end if
	}
 

In admin/changeuser.php find:

PHP Code

if ($avatar == "stock") {
	$picture = $avurl;
	$imagewidth = $avwidth;
	$imageheight = $avheight;
	$picupdate = 1;
}
 

and change to:

PHP Code

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);
		}
	} // end if

	$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.

Joined: Mar 2008
Posts: 326
D
Enthusiast
Enthusiast
D Offline
Joined: Mar 2008
Posts: 326
Thanks for taking the time to find and share a fix! smile

Joined: Jun 2006
Posts: 869
old hand
old hand
Joined: Jun 2006
Posts: 869
Will this resize avatars that people have uploaded themselves? Sometimes they are HUGE and slow down the loading of the page...?

Thanks


http://clubadventist.com/forums

No longer following the carrot
Joined: Jul 2006
Posts: 116
M
member
member
M Offline
Joined: Jul 2006
Posts: 116
@DLWebmaestro, no worries!

@Stan, this fix is purely for stock avatars. User uploaded avatars don't get resized, but simply scaled down to fit your defined limit. If filesize is the issue for you, then consider lowering the Maximum file size of uploaded avatars limit found under CP > Membership > Profile Settings.

Joined: Jun 2006
Posts: 869
old hand
old hand
Joined: Jun 2006
Posts: 869
[Linked Image from clubadventist.com]


http://clubadventist.com/forums

No longer following the carrot

Link Copied to Clipboard
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Recent Topics
spam issues
by ECNet - 03/19/2024 11:45 PM
Looking for a forum
by azr - 03/15/2024 11:26 PM
Editing Links in Post
by Outdoorking - 03/15/2024 9:31 AM
Question on barkrowler and the like
by Mors - 02/29/2024 6:51 PM
Member Permissions Help
by domspeak - 02/27/2024 6:31 PM
Who's Online Now
1 members (Havenofsobriety), 522 guests, and 99 robots.
Key: Admin, Global Mod, Mod
Random Gallery Image
Latest Gallery Images
Los Angeles
Los Angeles
by isaac, August 6
3D Creations
3D Creations
by JAISP, December 30
Artistic structures
Artistic structures
by isaac, August 29
Stones
Stones
by isaac, August 19
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20230217)