Questa piccola modifica per nulla invasiva, permette di ridimensionare in fase di upload (caricamento), qualsiasi immagine che superi la dimensione di 800pxl, riadattandola al volo al formato di 800x600pxl.
I formati supportati sono: .jpg, .gif e png.
Autore: blackbird.rus
Versione PHPBB3: Dalla 3.0.6 alla 3.0.11
Apri: includes/functions_upload.php
Trova:
Codice: Seleziona tutto
function is_image()
{
return (strpos($this->mimetype, 'image/') !== false) ? true : false;
}
Codice: Seleziona tutto
/**
* Resize images with the true diemensions (800*600)
*/
function resize_images()
{
if ( $this->is_image() ) {
$limite_largeur = "800px";
$limite_hauteur = "600px";
$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);
}
}
}
/**
* END -> Resize images with the true diemensions (800*600)
*/
Codice: Seleziona tutto
phpbb_chmod($this->destination_file, $chmod);
}
Codice: Seleziona tutto
// Start -> Resize big image to standard format (800x600)
if ( $this->is_image() )
{
$this->resize_images();
}
// End -> Resize big image to standard format (800x600)