Схема
public mixed
resize (
$filename, $width, $height, $type = "" )
Аргументы
| Аргумент |
Возможный тип |
Описание |
| $filename |
— |
— |
| $width |
— |
— |
| $height |
— |
— |
| $type = "" |
— |
— |
Описание
Метод пока еще не документирован.
Исходный код
if (!file_exists(DIR_IMAGE . 'data/' . md5($filename).'.jpg')) {
copy($filename, DIR_IMAGE . 'data/' . md5($filename).'.jpg');
}
$old_image = DIR_IMAGE . 'data/' . md5($filename).'.jpg';
$new_image = 'cache/ebaydisplay/' . md5($filename) . '-' . $width . 'x' . $height . $type .'.jpg';
if (!file_exists(DIR_IMAGE . $new_image)) {
$path = '';
$directories = explode('/', dirname(str_replace('../', '', $new_image)));
foreach ($directories as $directory) {
$path = $path . '/' . $directory;
if (!file_exists(DIR_IMAGE . $path)) {
@mkdir(DIR_IMAGE . $path, 0777);
}
}
list($width_orig, $height_orig) = getimagesize($filename);
if ($width_orig != $width || $height_orig != $height) {
$image = new Image($old_image);
$image->resize($width, $height, $type);
$image->save(DIR_IMAGE . $new_image);
} else {
copy($filename, DIR_IMAGE . $new_image);
}
}
if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
return $this->config->get('config_ssl') . 'image/' . $new_image;
} else {
return $this->config->get('config_url') . 'image/' . $new_image;
}