Extend Image class. Separate to ImageVariant. Remove _is_new_record.
This commit is contained in:
@ -19,7 +19,6 @@ abstract class Upload
|
||||
{
|
||||
$image = new Image;
|
||||
$image->original_filename = $file['name'];
|
||||
$image->type = $file['type'];
|
||||
$greagwar_image = self::getGreagwarImage($file['tmp_name']);
|
||||
self::saveImage($image, $greagwar_image);
|
||||
if ($force_create_variants) {
|
||||
@ -40,16 +39,17 @@ abstract class Upload
|
||||
*/
|
||||
public static function saveImage($image, $greagwar_image, $width = null, $height = null, $crop = true)
|
||||
{
|
||||
$greagwar_image = clone($greagwar_image);
|
||||
if ($width || $height) {
|
||||
$greagwar_image->resize($width, $height, 0xffffff, false, false, $crop);
|
||||
}
|
||||
$file_path = $greagwar_image->cacheFile($greagwar_image->guessType(), 87, true);
|
||||
$image->type = $greagwar_image->guessType();
|
||||
$file_path = $greagwar_image->cacheFile($image->type, 87, true);
|
||||
$image->size = filesize($file_path);
|
||||
$path_parts = pathinfo($file_path);
|
||||
$image->path = preg_replace('#^' . self::PATH_ROOT . '/#', '', $path_parts['dirname']);
|
||||
$image->filename = $path_parts['basename'];
|
||||
$image->width = $greagwar_image->width();
|
||||
$image->height = $greagwar_image->height();
|
||||
$image->setIsNotEmpty();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user