Resize Remote Avatars mod-Frage
Verfasst: 28.03.2006 19:00
Habe den Resize Remote Avatars mod eingebaut und ich habe jetzt von einer Möglichkeit gelesen, dass die Bilder automatisch kleiner gemacht werden. Bei mir kommt jedoch nur der Text aus der lang_main, dass das Avatar zu groß ist. Kann jemans mir sagen wie ich die funktions.php anpassen muss damit es paßt?!
mfg
A.U.
Code: Alles auswählen
// Start Resize Remote Avatars mod
function get_remote_img_tag( $url, $max_width, $max_height )
{
global $lang;
global $board_config;
$tag = '';
// @getimagesize returns false if the remote image is not found
$size = @getimagesize( $url );
if ( $size )
{
$width = $size[0];
$height = $size[1];
if ( $width > $max_width || $height > $max_height)
{
$tag = $lang['Avatar_too_large'];
}
// otherwise dynamically resize the avatar
else
{
$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'] . '"';
}
}
$tag = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $url . '" alt="" border="0"' . $width_attr . $height_attr . '/>' : '';
}
}
// if the image was not found, display a configurable message
else
{
$tag = $lang['Avatar_not_found'];
}
return $tag;
}
// End Resize Remote Avatars mod
A.U.
