/**
* Созданию превьюшек
* https://github.com/verot/class.upload.php
* @param string $file Путь к исходному файлу
* @param integer $x ширина
* @param integer $y высота
* @return string Путь к миниатрюре
*/
public static function createThumb($file, $x=500, $y=500) {
include_once conf::$pref_include."classes/class.upload.php";
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
$name = md5($file) . $x . $y;
$thumb = conf::$http . "images/thumbs/thumb_{$name}.jpeg";
$newfile = $_SERVER['DOCUMENT_ROOT'] . "/images/thumbs/{$name}." . $ext;
$thumbfile = $_SERVER['DOCUMENT_ROOT'] . "/images/thumbs/thumb_{$name}.jpeg";
if (file_exists($thumbfile)) {
return $thumb;
}
else if (@copy($file, $newfile) || @copy(conf::$pref_include . $file, $newfile)) {
$handle = new Upload($newfile);
$handle->file_overwrite = true; // перезаписать файл
$handle->image_resize = true;
$handle->image_ratio_crop = true;
$handle->image_x = $x;
$handle->image_y = $y;
$handle->image_convert = 'jpeg';
$handle->file_name_body_pre = 'thumb_';
$handle->process($_SERVER['DOCUMENT_ROOT'] . "/images/thumbs/");
return $thumb;
}
return $file;
}