Autostorlek på avatarerna
Moderatorer: Moderatorgrupp, Supportgrupp
Här kan du ställa frågor om problem med och drift av phpBB 3 (3.0.0 eller senare). Det är här du bör skapa en tråd om du har ett problem, vill ställa en fråga och vill ha ett svar. Gäller det något annat, var vänlig bläddra nedåt på forumindex.
Klicka här för att se våra allmänna forumregler.
Autostorlek på avatarerna
Någon som kan vara behjälplig?
Re: Autostorlek på avatarerna
Öppna includes/functions_posting.php och hitta create_thumbnail() funktionen.
Den börjar med:
Kod: Markera allt
/**
* Create Thumbnail
*/
function create_thumbnail($source, $destination, $mimetype)
{Kod: Markera allt
if (!file_exists($destination))
{
return false;
}
phpbb_chmod($destination, CHMOD_READ | CHMOD_WRITE);
return true;
}Kod: Markera allt
/**
* Create Thumbnail
*/
// MODIFICATION BY DION DESIGNS
function create_thumbnail($source, $destination, $mimetype, $new_width=0, $new_height=0)
{
// END MODIFICATION
global $config;
// MODIFICATION BY DION DESIGNS
if ($new_width == 0) {
// END MODIFICATION
$min_filesize = (int) $config['img_min_thumb_filesize'];
$img_filesize = (file_exists($source)) ? @filesize($source) : false;
if (!$img_filesize || $img_filesize <= $min_filesize)
{
return false;
}
// MODIFICATION BY DION DESIGNS
}
else {
$destination = $source;
}
// END MODIFICATION
$dimension = @getimagesize($source);
if ($dimension === false)
{
return false;
}
list($width, $height, $type, ) = $dimension;
if (empty($width) || empty($height))
{
return false;
}
// MODIFICATION BY DION DESIGNS
if ($new_width == 0) {
list($new_width, $new_height) = get_img_size_format($width, $height);
}
else if ($height > $new_height || $width > $new_width) {
$h_ratio = $new_height / $height;
$w_ratio = $new_width / $width;
$scale_factor = ($h_ratio < $w_ratio) ? $h_ratio : $w_ratio;
$new_width = ($h_ratio < $w_ratio) ? round($width * $scale_factor) : $new_width;
$new_height = ($w_ratio < $h_ratio) ? round($height * $scale_factor) : $new_height;
}
else {
return false;
}
// END MODIFICATION
// Do not create a thumbnail if the resulting width/height is bigger than the original one
if ($new_width >= $width && $new_height >= $height)
{
return false;
}
$used_imagick = false;
// Only use imagemagick if defined and the passthru function not disabled
if ($config['img_imagick'] && function_exists('passthru'))
{
if (substr($config['img_imagick'], -1) !== '/')
{
$config['img_imagick'] .= '/';
}
@passthru(escapeshellcmd($config['img_imagick']) . 'convert' . ((defined('PHP_OS') && preg_match('#^win#i', PHP_OS)) ? '.exe' : '') . ' -quality 85 -geometry ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" "' . str_replace('\\', '/', $destination) . '"');
if (file_exists($destination))
{
$used_imagick = true;
}
}
if (!$used_imagick)
{
$type = get_supported_image_types($type);
if ($type['gd'])
{
// If the type is not supported, we are not able to create a thumbnail
if ($type['format'] === false)
{
return false;
}
switch ($type['format'])
{
case IMG_GIF:
$image = @imagecreatefromgif($source);
break;
case IMG_JPG:
@ini_set('gd.jpeg_ignore_warning', 1);
$image = @imagecreatefromjpeg($source);
break;
case IMG_PNG:
$image = @imagecreatefrompng($source);
break;
case IMG_WBMP:
$image = @imagecreatefromwbmp($source);
break;
}
if (empty($image))
{
return false;
}
if ($type['version'] == 1)
{
$new_image = imagecreate($new_width, $new_height);
if ($new_image === false)
{
return false;
}
imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
}
else
{
$new_image = imagecreatetruecolor($new_width, $new_height);
if ($new_image === false)
{
return false;
}
// Preserve alpha transparency (png for example)
@imagealphablending($new_image, false);
@imagesavealpha($new_image, true);
imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
}
// If we are in safe mode create the destination file prior to using the gd functions to circumvent a PHP bug
if (@ini_get('safe_mode') || @strtolower(ini_get('safe_mode')) == 'on')
{
@touch($destination);
}
switch ($type['format'])
{
case IMG_GIF:
imagegif($new_image, $destination);
break;
case IMG_JPG:
imagejpeg($new_image, $destination, 90);
break;
case IMG_PNG:
imagepng($new_image, $destination);
break;
case IMG_WBMP:
imagewbmp($new_image, $destination);
break;
}
imagedestroy($new_image);
}
else
{
return false;
}
}
if (!file_exists($destination))
{
return false;
}
phpbb_chmod($destination, CHMOD_READ | CHMOD_WRITE);
return true;
}Hitta:
Kod: Markera allt
$prefix = $config['avatar_salt'] . '_';
$file->clean_filename('avatar', $prefix, $data['user_id']);Kod: Markera allt
$prefix = $config['avatar_salt'] . '_';
// MODIFICATION BY DION DESIGNS
// resize uploaded avatar
include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
@ini_set('memory_limit','64M');
create_thumbnail($file->get('filename'), '', '', $config['avatar_max_width'], $config['avatar_max_height']);
// END MODIFICATION
$file->clean_filename('avatar', $prefix, $data['user_id']);- Sinom
Re: Autostorlek på avatarerna
Den valda visningsbilden är 200 pixlar bred och 287 pixlar hög. Visningsbilder måste vara minst 20 pixlar breda och 20 pixlar höga, men får inte vara bredare än 90 pixlar eller högre än 90 pixlar.
Vad gör jag fel?
Re: Autostorlek på avatarerna
- Sinom
Vilka är online
Användare som besöker denna kategori: 2 och 0 gäster



