Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> CNB Your Account
Author Message
version
New Member
New Member



Joined: May 06, 2005
Posts: 8

PostPosted: Thu May 12, 2005 6:51 am Reply with quote

Hi here is a line of code from userinfo.php (cnb ya 440 b2)

echo "<img src='".$board_config[avatar_path]."/".$usrinfo[user_avatar]."'>"; { /type1


Is there a way so that code includes a max width and height?

thanks
 
View user's profile Send private message
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Thu May 12, 2005 7:10 am Reply with quote

Why not just add the width and height attribute?
 
View user's profile Send private message
version







PostPosted: Thu May 12, 2005 7:26 am Reply with quote

Raven wrote:
Why not just add the width and height attribute?



Its because I dont want to limit the upload size, i just need to limit the display size if that makes sense?

Ie. if members want to upload 640x480 thats ok but i dont want to display it no bigger than ??? x ???
 
Raven







PostPosted: Thu May 12, 2005 7:51 am Reply with quote

You could try (not tested)
Code:
$maxWidth = 480;

$maxHeight = 640;
$imgArray = getimagesize($board_config[avatar_path]."/".$usrinfo[user_avatar]);
$imgWidth  = $imgArray[0];
$imgHeight = $imgArray[1];
if ($imgWidth>$maxWidth) $imgWidth=$maxWidth;
if ($imgHeight>$maxHeight) $imgHeight=$maxHeight;
echo "<img width=\"$imgWidth\" height=\"$imgHeight\" src='".$board_config[avatar_path]."/".$usrinfo[user_avatar]."'>"; { /type1
 
Raven







PostPosted: Thu May 12, 2005 7:55 am Reply with quote

You could also use the tertiary operator. Instead of
Code:
if ($imgWidth>$maxWidth) $imgWidth=$maxWidth;

if ($imgHeight>$maxHeight) $imgHeight=$maxHeight;

you could use
Code:
$imgWidth = $imgWidth>$maxWidth ? $maxWidth : $imgWidth;

$imgHeight = $imgHeight>$maxHeight ? $maxHeight : $imgHeight;

Just a preference for some Smile
 
version







PostPosted: Thu May 12, 2005 9:12 am Reply with quote

thanks ill give it a go !
 
version







PostPosted: Mon May 16, 2005 4:04 am Reply with quote

Just thought I'd report back. It worked 1st time. Thank you very much.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> CNB Your Account

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©