mirror of
https://github.com/getgrav/grav.git
synced 2025-10-26 07:56:07 +01:00
Flex: Fixed cropping issues on edit
This commit is contained in:
@@ -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'];
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user