Уменьшает изображения до заданного размера. Просто некоторые пользователи загружают огромные скриншоты или постеры, а нам нужно чтобы изображения были 1024х768 например.
Открываем functions_upload.php
после
Код: Выделить всё
var $upload = '';
Код: Выделить всё
/**
* Resize images with the true diemensions (1024*768)
*/
function resize_images()
{
if ( $this->is_image() ) {
$limite_largeur = "1024px";
$limite_hauteur = "768px";
$size = getimagesize($this->destination_file);
$largeur = $size[0];
$hauteur = $size[1];
if($hauteur > $limite_hauteur OR $largeur > $limite_largeur)
{
if($largeur > $limite_largeur)
{
$hauteur = $hauteur / ($largeur / $limite_largeur);
$largeur = $limite_largeur;
}
if($hauteur > $limite_hauteur)
{
$largeur = $largeur / ($hauteur / $limite_hauteur);
$hauteur = $limite_hauteur;
}
$destination = imagecreatetruecolor($largeur, $hauteur);
if ( $this->extension == "jpg" || $this->extension == "jpeg" ) $source = imagecreatefromjpeg($this->destination_file);
elseif ( $this->extension == "png" ) $source = imagecreatefrompng($this->destination_file);
elseif ( $this->extension == "gif" ) $source = imagecreatefromgif($this->destination_file);
imagecopyresampled($destination, $source, 0, 0, 0, 0, $largeur, $hauteur, $size[0], $size[1]);
if ( $this->extension == "jpg" || $this->extension == "jpeg" ) imagejpeg($destination, $this->destination_file);
elseif ( $this->extension == "png" ) imagepng($destination, $this->destination_file);
elseif ( $this->extension == "gif" ) imagegif($destination, $this->destination_file);
}
}
}
Код: Выделить всё
phpbb_chmod($this->destination_file, $chmod);
Код: Выделить всё
if ( $this->is_image() )
{
$this->resize_images();
}
Для того чтобы смогли грузиться самые огромные изображения и не теряться изза нехватки памяти php - делаем следущее:
Открываем .htaccess (в корне форума)
добавляем
Код: Выделить всё
php_value memory_limit 128M