Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-29 20:20: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({
|
export default Ember.Component.extend({
|
||||||
classNames: ["wizard-field-upload"],
|
classNames: ["wizard-field-upload"],
|
||||||
uploading: false,
|
uploading: false,
|
||||||
|
isImage: false,
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this._super();
|
this._super();
|
||||||
|
@ -30,6 +31,12 @@ export default Ember.Component.extend({
|
||||||
"field.value": response.result,
|
"field.value": response.result,
|
||||||
"uploading": false
|
"uploading": false
|
||||||
});
|
});
|
||||||
|
console.log (response.result);
|
||||||
|
if (['jpg','jpeg','png','gif'].includes(response.result.extension)) {
|
||||||
|
this.setProperties({
|
||||||
|
"isImage": true
|
||||||
|
})
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$upload.on("fileuploadfail", (e, response) => {
|
$upload.on("fileuploadfail", (e, response) => {
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
|
|
||||||
{{#if field.value}}
|
{{#if field.value}}
|
||||||
<a href="{{field.value.url}}" class="filename">
|
<a href="{{field.value.url}}" class="filename">
|
||||||
|
{{#unless isImage}}
|
||||||
{{field.value.original_filename}}
|
{{field.value.original_filename}}
|
||||||
|
{{else}}
|
||||||
|
<img src={{field.value.url}} class="wizard-image-preview">
|
||||||
|
{{/unless}}
|
||||||
</a>
|
</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
Laden …
In neuem Issue referenzieren