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