From 74980fbdd75ad4a1efaf0731324c1a4c986b1d3b Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 14 Apr 2023 10:39:59 +0200 Subject: [PATCH] refs #5553 Insert/Update image table before save --- debian/changelog | 2 +- package.json | 2 +- rest/image/upload.php | 63 ++++++++++++++++++++++--------------------- 3 files changed, 34 insertions(+), 33 deletions(-) diff --git a/debian/changelog b/debian/changelog index 354d9990..25432462 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-web (23.6.9) stable; urgency=low +hedera-web (23.6.10) stable; urgency=low * Initial Release. diff --git a/package.json b/package.json index 5d777aef..b63f2d84 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hedera-web", - "version": "23.6.9", + "version": "23.6.10", "description": "Verdnatura web page", "license": "GPL-3.0", "repository": { diff --git a/rest/image/upload.php b/rest/image/upload.php index 8b998808..d3cbfef0 100644 --- a/rest/image/upload.php +++ b/rest/image/upload.php @@ -39,31 +39,31 @@ class Upload extends Vn\Web\JsonRequest { if ($_FILES['image']['error'] != 0) { switch ($_FILES['image']['error']) { - case UPLOAD_ERR_INI_SIZE: - $message = 'ErrIniSize'; - break; - case UPLOAD_ERR_FORM_SIZE: - $message = 'ErrFormSize'; - break; - case UPLOAD_ERR_PARTIAL: - $message = 'ErrPartial'; - break; - case UPLOAD_ERR_NO_FILE: - $message = 'ErrNoFile'; - break; - case UPLOAD_ERR_NO_TMP_DIR: - $message = 'ErrNoTmpDir'; - break; - case UPLOAD_ERR_CANT_WRITE: - $message = 'ErrCantWrite'; - break; - case UPLOAD_ERR_EXTENSION: - $message = 'ErrExtension'; - break; - default: - $message = 'ErrDefault'; - break; - } + case UPLOAD_ERR_INI_SIZE: + $message = 'ErrIniSize'; + break; + case UPLOAD_ERR_FORM_SIZE: + $message = 'ErrFormSize'; + break; + case UPLOAD_ERR_PARTIAL: + $message = 'ErrPartial'; + break; + case UPLOAD_ERR_NO_FILE: + $message = 'ErrNoFile'; + break; + case UPLOAD_ERR_NO_TMP_DIR: + $message = 'ErrNoTmpDir'; + break; + case UPLOAD_ERR_CANT_WRITE: + $message = 'ErrCantWrite'; + break; + case UPLOAD_ERR_EXTENSION: + $message = 'ErrExtension'; + break; + default: + $message = 'ErrDefault'; + break; + } throw new Lib\Exception(s($message)); } @@ -101,12 +101,6 @@ class Upload extends Vn\Web\JsonRequest { $symbolicSrc = "../full/$fileName"; $image = Image::create($tmpName); - Image::resizeSave($image, $fullFile, $info['maxHeight'], $info['maxWidth']); - - foreach ($info['sizes'] as $size => $i) { - $dstFile = "$collectionPath/$size/$fileName"; - Image::resizeSave($image, $dstFile, $i['height'], $i['width'], $i['crop'], $symbolicSrc); - } $query = "INSERT INTO `image` @@ -121,6 +115,13 @@ class Upload extends Vn\Web\JsonRequest { 'name' => $name ]); + Image::resizeSave($image, $fullFile, $info['maxHeight'], $info['maxWidth']); + + foreach ($info['sizes'] as $size => $i) { + $dstFile = "$collectionPath/$size/$fileName"; + Image::resizeSave($image, $dstFile, $i['height'], $i['width'], $i['crop'], $symbolicSrc); + } + imagedestroy($image); unlink($tmpName); return TRUE;