Игнор ошибок от unlink в File.

Upload - GreagwarImage сохранение не используется, если активирована библиотека PythonLibs/Image
This commit is contained in:
2014-05-14 14:05:14 +04:00
parent 7c886e1dbf
commit 83215978c3
2 changed files with 17 additions and 12 deletions

View File

@ -116,14 +116,14 @@ abstract class File
* @var $image Image * @var $image Image
*/ */
if ($this->getIsNoEmpty()) { if ($this->getIsNoEmpty()) {
unlink($this->getRealPath()); @unlink($this->getRealPath());
} }
if (get_parent_class($this) == 'Image') { if (get_parent_class($this) == 'Image') {
$image = $this; $image = $this;
foreach ($image->variants as $size) { foreach ($image->getSizes() as $size) {
$image_variant = $image->getVariant($size); $image_variant = $image->getVariant($size);
if ($image_variant->getIsNoEmpty()) { if ($image_variant->getIsNoEmpty()) {
unlink($image->getRealPath()); @unlink($image->getRealPath());
} }
} }
} }

View File

@ -113,15 +113,20 @@ abstract class Upload
} else { } else {
$greagwar_image = self::getGreagwarImage($tmp_file_path); $greagwar_image = self::getGreagwarImage($tmp_file_path);
} }
if ($width || $height) { $image->type = $greagwar_image->guessType();
if (!(ImageVariant::getIsClass($image)) && Image::getIsSubClass($image)) { if (!Config::get('PYTHON_PIL_RESIZE')) {
$greagwar_image->resize($width, $height, 0xffffff, $force = false, $rescale = false, $crop = true); if ($width || $height) {
} else { if (!(ImageVariant::getIsClass($image)) && Image::getIsSubClass($image)) {
$greagwar_image->resize($width, $height, 0xffffff, $force = false, $rescale = false, $crop = false); $greagwar_image->resize($width, $height, 0xffffff, $force = false, $rescale = false, $crop = true);
} } else {
} $greagwar_image->resize($width, $height, 0xffffff, $force = false, $rescale = false, $crop = false);
$image->type = $greagwar_image->guessType(); }
$file_path = $greagwar_image->cacheFile($image->type, $quality = 100, true); }
$file_path = $greagwar_image->cacheFile($image->type, $quality = 100, true);
} else {
$hash = $greagwar_image->getHash($image->type, $quality = 100);
$file_path = $greagwar_image->generateFileFromhash($hash);
}
$image->size = filesize($file_path); $image->size = filesize($file_path);
$path_parts = pathinfo($file_path); $path_parts = pathinfo($file_path);
$image->path = preg_replace('#^' . Config::get('PATH_WEB_ROOT') . '/#', '', $path_parts['dirname']); $image->path = preg_replace('#^' . Config::get('PATH_WEB_ROOT') . '/#', '', $path_parts['dirname']);