Flex: Fixed cropping issues on edit

This commit is contained in:
Matias Griese
2018-12-13 18:21:39 +02:00
parent 56c7b8ca5f
commit 8ba00f5967
2 changed files with 15 additions and 1 deletions

View File

@@ -45,6 +45,9 @@ trait FlexMediaTrait
case UPLOAD_ERR_OK:
break;
case UPLOAD_ERR_NO_FILE:
if ($uploadedFile instanceof FormFlashFile) {
break;
}
throw new RuntimeException($language->translate('PLUGIN_ADMIN.NO_FILES_SENT'), 400);
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
@@ -120,8 +123,12 @@ trait FlexMediaTrait
$file = YamlFile::instance($filepath . '.meta.yaml');
$file->save(['upload' => $metadata]);
}
if ($uploadedFile->getError() === \UPLOAD_ERR_OK) {
$uploadedFile->moveTo($filepath);
}
} else {
$uploadedFile->moveTo($filepath);
}
$uploadedFile->moveTo($filepath);
} catch (\Exception $e) {
$language = $grav['language'];

View File

@@ -370,12 +370,19 @@ class FormFlash implements \JsonSerializable
$originalUpload = $this->files[$field . '/original'][$name] ?? null;
if ($originalUpload) {
// If there is original file already present, remove the modified file
$originalUpload['crop'] = $crop;
$this->removeTmpFile($oldUpload['tmp_name'] ?? '');
} else {
// Otherwise make the previous file as original
$oldUpload['crop'] = $crop;
$this->files[$field . '/original'][$name] = $oldUpload;
}
} else {
$this->files[$field . '/original'][$name] = [
'name' => $name,
'type' => $data['type'],
'crop' => $crop
];
}
} else {
// Deal with replacing upload