Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 17:30:29 +01:00
FEATURE: added image preview for image uploads
Dieser Commit ist enthalten in:
Ursprung
938e29fe3f
Commit
1597e40a8a
2 geänderte Dateien mit 12 neuen und 1 gelöschten Zeilen
|
@ -4,6 +4,7 @@ import { getToken } from "wizard/lib/ajax";
|
|||
export default Ember.Component.extend({
|
||||
classNames: ["wizard-field-upload"],
|
||||
uploading: false,
|
||||
isImage: false,
|
||||
|
||||
didInsertElement() {
|
||||
this._super();
|
||||
|
@ -30,6 +31,12 @@ export default Ember.Component.extend({
|
|||
"field.value": response.result,
|
||||
"uploading": false
|
||||
});
|
||||
console.log (response.result);
|
||||
if (['jpg','jpeg','png','gif'].includes(response.result.extension)) {
|
||||
this.setProperties({
|
||||
"isImage": true
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
$upload.on("fileuploadfail", (e, response) => {
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
|
||||
{{#if field.value}}
|
||||
<a href="{{field.value.url}}" class="filename">
|
||||
{{#unless isImage}}
|
||||
{{field.value.original_filename}}
|
||||
{{else}}
|
||||
<img src={{field.value.url}} class="wizard-image-preview">
|
||||
{{/unless}}
|
||||
</a>
|
||||
{{/if}}
|
||||
|
|
Laden …
In neuem Issue referenzieren