Previous Thread
Next Thread
Print Thread
Hop To
7.5.3 Stock Avatars don't obey resolution limit #246040 09/28/2011 3:11 AM
Joined: Jul 2006
Posts: 116
Myke Offline OP
member
OP Offline
member
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.

Re: 7.5.3 Stock Avatars don't obey resolution limit [Re: Myke] #246213 10/05/2011 8:35 AM
Joined: Jul 2006
Posts: 116
Myke Offline OP
member
OP Offline
member
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.

Re: 7.5.3 Stock Avatars don't obey resolution limit [Re: Myke] #246214 10/05/2011 11:23 AM
Joined: Mar 2008
Posts: 326
DLWebmaestro Offline
Enthusiast
Offline
Enthusiast
Joined: Mar 2008
Posts: 326
Thanks for taking the time to find and share a fix! smile

Re: 7.5.3 Stock Avatars don't obey resolution limit [Re: Myke] #246229 10/06/2011 4:51 PM
Joined: Jun 2006
Posts: 869
Stan Offline
old hand
Offline
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
Re: 7.5.3 Stock Avatars don't obey resolution limit [Re: Myke] #246231 10/06/2011 5:59 PM
Joined: Jul 2006
Posts: 116
Myke Offline OP
member
OP Offline
member
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.

Re: 7.5.3 Stock Avatars don't obey resolution limit [Re: Myke] #246232 10/06/2011 6:54 PM
Joined: Jun 2006
Posts: 869
Stan Offline
old hand
Offline
old hand
Joined: Jun 2006
Posts: 869
[Linked Image]


http://clubadventist.com/forums

No longer following the carrot

Forum Search
ShoutChat Box
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Recent Topics
What happened to FAQ or Forum Help
by Ruben - 11/20/2019 11:58 AM
Search feature encountering an Error message
by jorb - 11/20/2019 12:06 AM
Followed List v7.7.2 Question
by Ruben - 11/12/2019 12:22 PM
UBB Dev
by JAISP - 11/03/2019 11:01 AM
Exceeded Number of attachments
by rbrtgrmn - 11/02/2019 9:57 PM
Who's Online Now
3 registered members (Gizmo, JAISP, isaac), 58 guests, and 455 spiders.
Key: Admin, Global Mod, Mod
Random Gallery Image
Latest Gallery Images
Artistic structures
Artistic structures
by isaac, August 29
Stones
Stones
by isaac, August 19
Amusing Terain Scenics
Amusing Terain Scenics
by isaac, August 19
Sky places
Sky places
by isaac, August 19
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Snapshot build 20191023)