Код: Выделить всё
##############################################################
## MOD Title: Resize Remote Avatars v1.0.0
##
## MOD Author: Scott Ellis < srellis@orci.com > (Scott Ellis)
##
## MOD Description:
##
## Dynamically resize remote avatars to fit the maximum size set in the admin control panel
## - users can link their avatar to any image on the web and it will be
## automatically resized to fit the maximum dimensions set in the ACP
## - aspect ratio is maintained
##
## MOD Version: 1.0.0
##
## Installation Level: Easy
##
## Installation Time: < 1 Minute
##
## Files To Edit: viewtopic.php
##
## Included Files: n/a
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/
##############################################################
## Author Notes:
## -----------
## developed and tested on phpBB 2.0.6
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ OPEN ]------------------------------------------
#
viewtopic.php
#
#-----[ FIND ]------------------------------------------
#
$poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
#
#-----[ REPLACE WITH ]------------------------------------------
#
////////////////////////////////////////////////////////
// Resize Remote Avatars mod
// Make sure that both dimensions of remote avatars conform to the limits
// set in the admin control panel. Use the width and height attributes
// on the <img> tag to control the image size in the browser.
// Reduce the largest dimension of the remote image to the maximum allowed
// in the ACP, then reduce the other dimension to maintain the aspect ratio.
//
// phpbb 2.0.6 impl
// $poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
// new impl
list($width, $height) = @getimagesize($postrow[$i]['user_avatar']);
$width_attr = '';
$height_attr = '';
// resize the avatar in the browser if either dimension is too large
$resize = $width > $board_config['avatar_max_width'] || $height > $board_config['avatar_max_height'];
// set max dimension and adjust the other according to the ratio
if ( $resize )
{
if ( $width == $height )
{
$width_attr = ' width="' . $board_config['avatar_max_width'] . '"';
$height_attr = ' height="' . $board_config['avatar_max_height'] . '"';
}
else if ( $width > $height )
{
$width_attr = ' width="' . $board_config['avatar_max_width'] . '"';
$height_attr = ' height="' . $board_config['avatar_max_width'] * $height / $width . '"';
}
else // $height > $width
{
$width_attr = ' width="' . $board_config['avatar_max_height'] * $width / $height . '"';
$height_attr = ' height="' . $board_config['avatar_max_height'] . '"';
}
}
$poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $postrow[$i]['user_avatar'] . '" alt="" border="0"' . $width_attr . $height_attr . '/>' : '';
// end Resize Remote Avatars mod
////////////////////////////////////////////////////////
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM