Page 1 of 1

[MOD] Better avatar restriction on blocks

PostPosted: Sun May 07, 2006 6:29 am
Author: evolver
This is an improvement for the display of avatars in Blocks...

The 'user block' and the 'top posters block' display avatars.
  • In the 'user block', the avatar wasn't resized at all.
  • In the 'top posters block', avatars are resized in height only.
I didn't like it that way, because this can stretch the block width!!

It can happen when users use larger avatar's,
but it will also happen when avatars are restricted by a maximum avatar width larger than block-width!!

And woooh, have you ever seen what happens with extra wide avatars?
When you're using the '[url=http]remote avatar resizer MOD[/url]', avatars on 'viewtopic' will handle it just fine,
but on the 'portal page', blocks displaying avatars will stretch out completely!!!
[align=right][size=99px]http://www.aero.com/IMAGES/TOPBAR.JPG[/url][/size][/align:18pz9txa]
Sure, users aren't supposed to use avatars like this!!
But I really don't like this to be possible...
We have to avoid this if we can!!

So here, I have used the '[url=http]remote avatar resizer MOD[/url]'-code to put better avatar restrictions on those blocks as well.
It wasn't just copy and paste, mind you.
In stead of using the usual maximum widht and height restrictions, I have applied other restictions.
For maximum width]block-width[/b] - block-borders (15)
For maximum height, I used the restriction that was already there for the 'top posters block']md_avatar_height[/b]

I've found the code for getting block-width on viewtopic.php
Viewtopic uses that for the 'no_thread-stretch MOD' by the way.
So, I only had to copy that piece of code to those blocks as well.

Because these restictions on blocks became different,
I also had to put the same restiction on ALL avatars (not only remote-avatars).

[align=right:18pz9txa][size=99px]

User block

PostPosted: Sun May 07, 2006 6:44 am
Author: evolver
[size=99px]

[size=99px]http]  *   email                ] )         {          $sql = "SELECT COUNT(post_id) as total                FROM " . POSTS_TABLE . "                WHERE post_time >= " . $userdata['user_lastvisit'] . " AND poster_id <userdata>sql_query($sql);             if( $result )             {                 $row = $db->sql_fetchrow($result);                 $lang['Search_new'] = $lang['Search_new'] . " (" . $row['total'] . ")";             }         }                   // ------------------------------------                 // Getting block width to apply a maximum avatar width & height                 // ------------------------------------                 $block_width = 0;                 if($portal_config['portal_header'])                 {                     $block_width = $block_width + $portal_config['header_width'];                 }                 if($portal_config['portal_tail'])                 {                     $block_width = $block_width + $portal_config['footer_width'];                 }                 // ------------------------------------           $avatar_img = '';                   $width = 0;                 $height = 0;                                 // Default avatars LOCATION                   $helpavatardir = 'templates/' . $theme['template_name'] . '/images/lang_' . $board_config['default_lang'] . '/';                 $default_avatar = '<img>';                 // No default for guests                   $avatar_upload_unavailable = '<img>';                 $avatar_remote_unavailable = '<img>';                 $avatar_gallery_unavailable = '<img>';                 // ------------------------                                 $uploadurl = ($board_config['avatar_path'] . '/' . $userdata['user_avatar']);                 $remoteurl = $userdata['user_avatar'];                 $galleryurl = ($board_config['avatar_gallery_path'] . '/' . $userdata['user_avatar']);           if ( $userdata['user_avatar_type'] && $userdata['user_allowavatar'] )         {             switch( $userdata['user_avatar_type'] )             {                                   case USER_AVATAR_UPLOAD:                                             list($width, $height) = @getimagesize($uploadurl);                                             if ($width != 0)                                             {                                               // Resized when needed                                               // To avoid avatars stretching block                                               $percentage = ($height / $width * 100);                                               $blockmaxwidth = ($block_width - 15);                                               $newheight = round($blockmaxwidth * $percentage / 100);                                               if ( ($width > $blockmaxwidth) && ($newheight <blockmaxwidth> $blockmaxwidth)                                               {                                                 $avatar_img = ( $board_config['allow_avatar_upload'] ) ? '<img>' : '';                                               }                                               else  // no need to resize                                               {                                                 $avatar_img = ( $board_config['allow_avatar_upload'] ) ? '<img>' : '';                                               }                                             }                                     else  // avatar image not available                                             {                                               // $avatar_img = '';                                               // This modification will display a warning when uploaded avatar is unavailable                                               $avatar_img = $avatar_upload_unavailable;                                             }                                             break;                                   case USER_AVATAR_REMOTE:                                             list($width, $height) = @getimagesize($remoteurl);                                             if ($width != 0)                                             {                                               // Resized when needed                                               // To avoid avatars stretching block                                               $percentage = ($height / $width * 100);                                               $blockmaxwidth = ($block_width - 15);                                               $newheight = round($blockmaxwidth * $percentage / 100);                                               if ( ($width > $blockmaxwidth) && ($newheight <blockmaxwidth> $blockmaxwidth)                                               {                                                 $avatar_img = ( $board_config['allow_avatar_remote'] ) ? '<img>' : '';                                               }                                               else  // no need to resize                                               {                                                 $avatar_img = ( $board_config['allow_avatar_remote'] ) ? '<img>' : '';                                               }                                             }                                     else  // avatar image not available                                             {                                               // $avatar_img = '';                                               // This modification will display a warning when remote-avatar is unavailable                                               $avatar_img = $avatar_remote_unavailable;                                             }                                             break;                                   case USER_AVATAR_GALLERY:                                             list($width, $height) = @getimagesize($galleryurl);                                             if ($width != 0)                                             {                                               // Resized when needed                                               // To avoid avatars stretching block                                               $percentage = ($height / $width * 100);                                               $blockmaxwidth = ($block_width - 15);                                               $newheight = round($blockmaxwidth * $percentage / 100);                                               if ( ($width > $blockmaxwidth) && ($newheight <blockmaxwidth> $blockmaxwidth)                                               {                                                 $avatar_img = ( $board_config['allow_avatar_local'] ) ? '<img>' : '';                                               }                                               else  // no need to resize                                               {                                                 $avatar_img = ( $board_config['allow_avatar_local'] ) ? '<img>' : '';                                               }                                             }                                     else  // avatar image not available                                             {                                               // $avatar_img = '';                                               // This modification will display a warning when gallery-avatar is unavailable                                               $avatar_img = $avatar_gallery_unavailable;                                             }                                             break;             }         }                         // Default avatar MOD, By Manipe - modified for Integramod by Evolver (Begin)                 if (!$avatar_img)                 {                   $avatar_img = $default_avatar;         }                 // Default avatar MOD, By Manipe - modified for Integramod by Evolver (End)                   if ($userdata['user_id'] != '-1')         {             $name_link = '<a>' . $userdata['username'] . '</a>';         }         else         {             $name_link = $lang['Guest'];         }           $template->assign_vars(array(             'AVATAR_IMG' => $avatar_img,             'U_NAME_LINK' => $name_link,             'L_REMEMBER_ME' => $lang['Remember_me'],             'L_SEND_PASSWORD' => $lang['Forgotten_password'],             'U_SEND_PASSWORD' => append_sid("profile.$phpEx?mode=sendpassword"),             'L_REGISTER_NEW_ACCOUNT' => sprintf($lang['Register_new_account'], '<a>', '</a>'),             'L_NEW_SEARCH' => $lang['Search_new']             )         );     }}  imp_user_block_block_func();?>[/code]

top_posters block

PostPosted: Sun May 07, 2006 7:05 am
Author: evolver
[size=99px]http]  *   email                ]http://www.integramod.com[/url]  *   email                : <a>webmaster@integramod.com</a>  *  *   note: removing the original copyright is illegal even you have modified  *         the code.  Just append yours if you have modified it.  ***************************************************************************/  /***************************************************************************  *  *   This program is free software; you can redistribute it and/or modify  *   it under the terms of the GNU General Public License as published by  *   the Free Software Foundation; either version 2 of the License, or  *   (at your option) any later version.  *  ***************************************************************************/  if ( !defined('IN_PHPBB') ){     die("Hacking attempt");}  $block_count_variables = 2;  // array( <Field>, <Field>, <Config>, <Options>, <Field>, <Control>, <Block>, <Default>);  $block_variables = array(     array('Number of Top Posters', '', 'md_total_poster', '', '', '1', 'top_posters', '5'),     array('Height of Avatars Displayed', 'in pixels', 'md_avatar_height', '', '', '1', 'top_posters', '40')     );?>[/code]

Re: [MOD] Better avatar restriction on blocks

PostPosted: Sun May 28, 2006 12:01 am
Author: evolver
User-Block and TopPosters-block updated <img>

I have updated:
blocksblocks_imp_user_block.php and
blocksblocks_imp_top_posters.php

In previous posts...

I've changed the max-height for the User-Block to be the same as max-width (being block-width),
instead of using the 'md_avatar_height' as set for the TopPosters-Block...

Default avatar made possible...
(It will work without them, it's only an option)
I will explain later how to use the option...

Re: [MOD] Better avatar restriction on blocks

PostPosted: Mon Jul 03, 2006 6:11 pm
Author: Threat009
Any chance of integrating top posters block w/default avatar mod? You may have noticed the top poster block is designed to display avatar, username, and posts, however if the user has not yet set an avatar the space is just blank <img>