Add present image
This commit is contained in:
parent
a30e039cb6
commit
e54425379b
|
@ -30,12 +30,14 @@ class UploadStorage {
|
|||
'crop' => $this->data['crop']
|
||||
]);
|
||||
|
||||
return $sourcePath.'/'.$fileName;
|
||||
return $this->getFileData($sourcePath.'/'.$fileName);
|
||||
}
|
||||
|
||||
public function getFileData($filename) {
|
||||
$realname = preg_replace('/^source/', 'cropped', $filename);
|
||||
|
||||
$realname = $this->storage()->exists($realname) ? $realname : $filename;
|
||||
|
||||
return [
|
||||
'url' => $this->storage()->url($realname),
|
||||
'type' => $this->storage()->mimeType($filename),
|
||||
|
|
|
@ -137,15 +137,6 @@ class Responsiveimage extends FormWidgetBase
|
|||
return $record;
|
||||
}
|
||||
|
||||
public function getLoadValue() {
|
||||
$value = parent::getLoadValue();
|
||||
if (!$value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return app(UploadStorage::class)->getFileData($value['file']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the escaped and translated prompt text to display according to the type.
|
||||
* @return string
|
||||
|
|
|
@ -111,6 +111,9 @@ export default {
|
|||
asString() {
|
||||
return JSON.stringify(this.content);
|
||||
},
|
||||
formData() {
|
||||
return $(this.$el).closest('form').serializeArray();
|
||||
},
|
||||
dropzoneOptions() {
|
||||
return {
|
||||
paramName: 'file_data',
|
||||
|
@ -170,12 +173,15 @@ export default {
|
|||
},
|
||||
onSend(file, xhr, formData) {
|
||||
formData.append('extraData', JSON.stringify(this.extraData[file.name]));
|
||||
this.formData.forEach((v) => {
|
||||
formData.append(v.name, v.value);
|
||||
});
|
||||
},
|
||||
onMount() {
|
||||
if (this.value === null) { return; }
|
||||
if (!this.value) { return; }
|
||||
this.addVisible = false;
|
||||
var file = { size: this.value.size, name: this.value.name, type: this.value.type };
|
||||
this.$refs.dropzone.manuallyAddFile(file, this.value.url);
|
||||
var file = { size: this.value.file.size, name: this.value.file.name, type: this.value.file.type };
|
||||
this.$refs.dropzone.manuallyAddFile(file, this.value.file.url);
|
||||
},
|
||||
onRemove(file, error, xhr) {
|
||||
var _cls = this;
|
||||
|
|
Loading…
Reference in New Issue