Site Links
Home
Features
Documentation
Pricing & Order
Members Area
Support Options
UBBDev.com
UBBWiki.com
Who's Online
2 registered (Gizmo, SteveS), 38 Guests and 14 Spiders online.
Key: Admin, Global Mod, Mod
Featured Member
Registered: 06/07/07
Posts: 4
Top Posters (30 Days)
Ruben 50
DennyP 24
Gizmo 23
Dunny 15
SteveS 13
AllenAyres 12
dbremer 10
SD 10
drkknght00 9
doug 8
Latest Photos
OK Corral Shoot Out
Testing
Basildon Train Station
Basildon Town Centre looking from the rounderbout
Basildon Town Square
Topic Options
#246040 - 09/28/11 04:11 AM 7.5.3 Stock Avatars don't obey resolution limit
Myke Offline
member
Registered: 07/07/06
Posts: 119
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.
Top
Express Hosting
Express Hosting "We are the official hosting company of UBB.threads. Ask us about our free migration services to migrate your UBB.threads installation."
#246213 - 10/05/11 09:35 AM Re: 7.5.3 Stock Avatars don't obey resolution limit [Re: Myke]
Myke Offline
member
Registered: 07/07/06
Posts: 119
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.
Top
#246214 - 10/05/11 12:23 PM Re: 7.5.3 Stock Avatars don't obey resolution limit [Re: Myke]
DLWebmaestro Offline
enthusiast
Registered: 03/26/08
Posts: 333
Loc: North Carolina
Thanks for taking the time to find and share a fix! smile
_________________________
Marching Percussion ( Drumline ) Community
Top
#246229 - 10/06/11 05:51 PM Re: 7.5.3 Stock Avatars don't obey resolution limit [Re: Myke]
Stan Offline

old hand
Registered: 06/05/06
Posts: 709
Will this resize avatars that people have uploaded themselves? Sometimes they are HUGE and slow down the loading of the page...?

Thanks
Top
#246231 - 10/06/11 06:59 PM Re: 7.5.3 Stock Avatars don't obey resolution limit [Re: Myke]
Myke Offline
member
Registered: 07/07/06
Posts: 119
@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.
Top
#246232 - 10/06/11 07:54 PM Re: 7.5.3 Stock Avatars don't obey resolution limit [Re: Myke]
Stan Offline

old hand
Registered: 06/05/06
Posts: 709
Top



Moderator:  AllenAyres, Harold, Ian, Ron M 
Shout Box

Today's Birthdays
No Birthdays
Recent Topics
Temporary Password email not being received
by
05/24/12 10:02 PM
Ability to "like" individual posts (not Facebook "likes)
by doug
05/23/12 09:03 AM
Island Permissions
by ThreadsUser
05/22/12 03:03 PM
streaming video
by prkrgrp
05/20/12 07:02 PM
New Posts Corrupted? Can someone help?
by PianoWorld
05/19/12 09:41 AM
Forum Stats
10492 Members
36 Forums
33842 Topics
181709 Posts

Max Online: 978 @ 06/24/07 11:19 PM
Random Image