First Poster's Avatar's Width And Height


Goto page 1, 2  Next

Subject: First Poster's Avatar's Width And Height
I dunno if this is a real bug... anyway, the avatar (remotely hosted) of the person who opens a topic is 80x80 even if in the configuration of the max avatar width and height isn't set to 80x80.
The "bug" is in functions.php, line 1878
find:
Code: [Download] [Hide] [Select]
return ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $avatar_url . '" width="80" height="80" alt="" border="0" />' : '';

replace with:
Code: [Download] [Hide] [Select]
return ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $avatar_url . '" alt="" border="0" />' : '';

Subject: Respuesta: First Poster's Avatar's Width And Height
Thanks AvrilBoi. I have replaced that line but now the remote avatars are not resized to the size that I have assigned in the ACP...

Why? :(

Sorry for my bad english :oops:

In Spanish:

Gracias AvrilBoy. Yo he remplazado esa linea pero ahora los avatares externos no son redimensionados al tamaño que he puesto de maximo en el ACP...

¿Porque?

Profile PM  
Subject: Re: First Poster's Avatar's Width And Height
Don't worry, your English is good and understandable.
I don't know very well php, someone who is expert should find a solution to resize proportionally the remotely hosted avatars.
For now I prefer having the remotely hosted avatars in the original size than having them 80x80, and if I find someone who passes my limits, I'll send him a PM, because the limits are written in the general furum's rules.
Anyway you can disallow users to use remotely hosted avatars, so the only thing they can do is to upload or transload only avatars which don't pass the limits you set.

Subject: Respuesta: First Poster's Avatar's Width And Height
AvrilBoi wrote: [View Post]
Don't worry, your English is good and understandable.
I don't know very well php, someone who is expert should find a solution to resize proportionally the remotely hosted avatars.
For now I prefer having the remotely hosted avatars in the original size than having them 80x80, and if I find someone who passes my limits, I'll send him a PM, because the limits are written in the general furum's rules.
Anyway you can disallow users to use remotely hosted avatars, so the only thing they can do is to upload or transload only avatars which don't pass the limits you set.


Thanks, I will do that while we found some solution.

I think that it would be possible to adapt the code used for resize proportionally hosted avatars, for the remotely hosted avatars...

If this is possible, I believe that it isn't difficult...

Somebody can do it?

Profile PM  
Subject: Re: First Poster's Avatar's Width And Height
A check on the image should be performed to make sure that proportion are maintaned... :roll:

Anyway, what I suggest is to set just the width (which is the dimension which causes stretching) and leave the height as float. This will be a problem only with tall images... but it's better than having stretched images... :wink:

Try this:
Code: [Download] [Hide]
  1. return ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $avatar_url . '" width="80" alt="" border="0" />' : ''; 


Let me know. :wink:

Subject: Re: First Poster's Avatar's Width And Height
Mighty Gorgon wrote: [View Post]
but it's better than having stretched images...

But if an user has an avatar of 30 pixel in width, then the avatar will not be stretched but widened :(
So I still prefer having the remotely hosted avatars in the real size until we find a solution to resize them proportionally :wink:

Subject: Respuesta: First Poster's Avatar's Width And Height
AvrilBoi wrote: [View Post]
Mighty Gorgon wrote: [View Post]
but it's better than having stretched images...

But if an user has an avatar of 30 pixel in width, then the avatar will not be stretched but widened :(
So I still prefer having the remotely hosted avatars in the real size until we find a solution to resize them proportionally :wink:


Yes, I also ;)

Thanks

Profile PM  
Subject: Re: First Poster's Avatar's Width And Height
I think I have the solution, but since it may slow down page loading I won't add it to XS... :wink:

It uses getimagesize function:
Code: [Download] [Hide] [Select]
function resize_avatar($avatar_url)
{
global $board_config;
$avatar_width = 80;
$avatar_height = 80;
if (function_exists('getimagesize'))
{
$pic_size = @getimagesize($avatar_url);
if ($pic_size != false)
{
$pic_width = $pic_size[0];
$pic_height = $pic_size[1];
if ( ($pic_width < 80) && ($pic_height < 80) )
{
$avatar_width = $pic_width;
$avatar_height = $pic_height;
}
elseif ($pic_width > $pic_height)
{
$avatar_width = 80;
$avatar_height = 80 * ($pic_height/$pic_width);
}
else
{
$avatar_height = 80;
$avatar_width = 80 * ($pic_width/$pic_height);
}
}
}
return ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $avatar_url . '" width="'. $avatar_width .'" height="' . $avatar_height .'" alt="" border="0" />' : '';
}


Can you try this and let me know if it works please?

Subject: Re: First Poster's Avatar's Width And Height
Sure I try it ;)
Do I have to replace
Code: [Download] [Hide]
  1. return ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $avatar_url . '" alt="" border="0" />' : ''; 

with the code you provided?

Subject: Re: First Poster's Avatar's Width And Height
The whole function... :wink:

Subject: Re: First Poster's Avatar's Width And Height
I did it.
Here's what I gotta say :wink:
- thanks for providing the modification
- it works but doesn't use my configuration for the max. avatar width and height, but it uses 80px as maximum width and height
- it slows down the forum tooooooo much (you said that)
A solution for making the forum unslow could be to simply add the check for remotely hosted avatars just when the user changes / adds his remot. hosted avatar. If the avatar passes the limits, he has to put another url, if the avatar doesn't pass the limits, the remotely hosted avatar's url is saved in the profile... :roll:

Subject: Re: First Poster's Avatar's Width And Height
He he he... I know that getimagesize function is a pain in the ass for most host... :wink:

Many users have problems with that function, and most of the images problems are related to that one.

At the moment I don't have the time to modify the remote avatar feature... you may do some test if you wish... you can use the same function... :wink:

Subject: Re: First Poster's Avatar's Width And Height
Ok Mighty, I'll do some tests by myself... ^^ ;) But can you just tell me which is the file to modify? The one that has to check for the remotely hosted avatar when the users changes his avatar. Maybe usercp_avatar.php ? thanks

Subject: Re: First Poster's Avatar's Width And Height
Of course...

includes/usercp_avatar.php

Enjoy! :LOL:

Subject: Re: First Poster's Avatar's Width And Height
I found a mod for phpbb that is (almost) fully compatible with xs.
Maybe you can include this in the next patch/release of XS :wink: .
Code: [Download] [Hide] [Select]
#
#-----[ OPEN ]------------------------------------------
#
includes/usercp_avatar.php

#
#-----[ FIND ]------------------------------------------
#
return ( $mode == 'editprofile' ) ? ", user_avatar = '" . str_replace("'", "''", $avatar_filename) . "', user_avatar_type = " . USER_AVATAR_REMOTE : '';

#
#-----[ BEFORE, ADD ]------------------------------------------
#
// Start Remote Avatar Check Mod
global $board_config;

$remote_file = @fopen ($avatar_filename, "rb");

if(!$remote_file)
{
$error = true;
$error_msg = sprintf($lang['Remote_avatar_no_image'], $avatar_filename);
return;
}

$user_avatar_size = 0;
do
{
if (strlen(@fread($remote_file, 1)) == 0 || $user_avatar_size > $board_config['avatar_filesize'])
{
break;
}
$user_avatar_size ++;
}
while(true);
@fclose($remote_file);

if($user_avatar_size > $board_config['avatar_filesize'])
{
$error = true;
$error_msg = sprintf($lang['Remote_avatar_error_filesize'], $board_config['avatar_filesize']);
return;
}

list($user_avatar_width, $user_avatar_height) = @getimagesize($avatar_filename);

if($user_avatar_width > $board_config['avatar_max_width'] || $user_avatar_height > $board_config['avatar_max_height'])
{
$error = true;
$error_msg = sprintf($lang['Remote_avatar_error_dimension'], $board_config['avatar_max_width'], $board_config['avatar_max_height']);
return;
}
// End Remote Avatar Check Mod
#
#-----[ OPEN ] (do it with each language if you need to)
#
language/lang_*/lang_main.php

#
#-----[ FIND ]------------------------------------------
#
//
// Common, these terms are used
// extensively on several pages

#
#-----[ BEFORE, ADD ]------------------------------------------
#
// Start Remote Avatar Check Mod
$lang['Remote_avatar_no_image'] = 'The image %s does not exist';
$lang['Remote_avatar_error_filesize'] = 'The image is over the size limit for avatars (%d Bytes)';
$lang['Remote_avatar_error_dimension'] = 'The image is over the dimension limit for avatars (%d x %d pixels)';
// End Remote Avatar Check Mod

Here's also the patch (including Italian language file).


check_remote_avatar.zip
Description:  
Download
Filename: check_remote_avatar.zip
Filesize: 59.46 KB
Downloaded: 309 Time(s)

Goto page 1, 2  Next

Page 1 of 2


  
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events

   

This is a "Lo-Fi" version of our main content. To view the full version with more information, formatting and images, please click here.

Powered by Icy Phoenix based on phpBB
Generation Time: 0.1056s (PHP: 20% SQL: 80%)
SQL queries: 12 - Debug Off - GZIP Enabled