- allow empty input

- allow svg avatar
This commit is contained in:
Peter Papp
2021-05-06 10:08:58 +02:00
parent 86b6844d62
commit bd881da856
4 changed files with 25 additions and 15 deletions
+12 -6
View File
@@ -290,14 +290,20 @@ function store_avatar($request, $name)
// Store avatar
$image_path = Str::random(16) . '-' . $image->getClientOriginalName();
// Create intervention image
$img = Image::make($image->getRealPath());
if (in_array($image->getClientMimeType(), ['image/gif', 'image/jpeg', 'image/jpg', 'image/png', 'image/webp'])) {
// Create intervention image
$img = Image::make($image->getRealPath());
// Generate thumbnail
$img->fit('150', '150')->stream();
// Generate thumbnail
$img->fit('150', '150')->stream();
// Store thumbnail to disk
Storage::put("avatars/$image_path", $img);
// Store thumbnail to disk
Storage::put("avatars/$image_path", $img);
}
if ($image->getClientMimeType() === 'image/svg+xml') {
Storage::putFileAs('avatars', $image, $image_path);
}
// Return path to image
return "avatars/$image_path";
+8 -2
View File
@@ -20,7 +20,7 @@
"/chunks/app-language.js": "/chunks/app-language.js?id=ccf2292ad048d4bfad60",
"/chunks/app-language~chunks/app-settings~chunks/dashboard~chunks/dashboard-oasis~chunks/invoices~chun~93101a7f.js": "/chunks/app-language~chunks/app-settings~chunks/dashboard~chunks/dashboard-oasis~chunks/invoices~chun~93101a7f.js?id=93fb27b76209e5b7b2d9",
"/chunks/app-language~chunks/dashboard~chunks/dashboard-oasis~chunks/files~chunks/invoices~chunks/oasi~c6e9de01.js": "/chunks/app-language~chunks/dashboard~chunks/dashboard-oasis~chunks/files~chunks/invoices~chunks/oasi~c6e9de01.js?id=f9af3b7905bb7c35023d",
"/chunks/app-others.js": "/chunks/app-others.js?id=9156adba3b1697a8bf3e",
"/chunks/app-others.js": "/chunks/app-others.js?id=98970c52f69ab8ae1bc9",
"/chunks/app-payments.js": "/chunks/app-payments.js?id=7e1a982c90174f568fb2",
"/chunks/app-settings.js": "/chunks/app-settings.js?id=acc6ba7a93681f0d5d64",
"/chunks/app-setup.js": "/chunks/app-setup.js?id=d0e3e046e147ca928f34",
@@ -421,5 +421,11 @@
"/chunks/platform~chunks/shared.6c21d61908391d289fde.hot-update.js": "/chunks/platform~chunks/shared.6c21d61908391d289fde.hot-update.js",
"/chunks/platform~chunks/shared.1107858fead4e99c0777.hot-update.js": "/chunks/platform~chunks/shared.1107858fead4e99c0777.hot-update.js",
"/chunks/platform~chunks/shared.8ecbc2534cc15edb24c7.hot-update.js": "/chunks/platform~chunks/shared.8ecbc2534cc15edb24c7.hot-update.js",
"/chunks/platform~chunks/shared.726c307ce12d01d3d14b.hot-update.js": "/chunks/platform~chunks/shared.726c307ce12d01d3d14b.hot-update.js"
"/chunks/platform~chunks/shared.726c307ce12d01d3d14b.hot-update.js": "/chunks/platform~chunks/shared.726c307ce12d01d3d14b.hot-update.js",
"/js/main.1342e30369dc66c18368.hot-update.js": "/js/main.1342e30369dc66c18368.hot-update.js",
"/chunks/app-others.1c89c0d9ff0756cf8526.hot-update.js": "/chunks/app-others.1c89c0d9ff0756cf8526.hot-update.js",
"/js/main.6e42083eb30e9061f9f1.hot-update.js": "/js/main.6e42083eb30e9061f9f1.hot-update.js",
"/js/main.eee1ffd3fe3caa473ed0.hot-update.js": "/js/main.eee1ffd3fe3caa473ed0.hot-update.js",
"/js/main.168fcbb1cfee63eab722.hot-update.js": "/js/main.168fcbb1cfee63eab722.hot-update.js",
"/js/main.677f002e2ff871016185.hot-update.js": "/js/main.677f002e2ff871016185.hot-update.js"
}
+2 -4
View File
@@ -29,11 +29,9 @@ const Helpers = {
}
}, 300)
Vue.prototype.$updateText = debounce(function (route, name, value) {
Vue.prototype.$updateText = debounce(function (route, name, value, allowEmpty = false) {
let enableEmptyInput = ['mimetypes_blacklist', 'google_analytics', 'upload_limit']
if (value === '' || value === ' ' && !enableEmptyInput.includes(name)) return
if ((value === '' || value === ' ') && !allowEmpty) return
axios.post(this.$store.getters.api + route, {name, value, _method: 'patch'})
.catch(() => {
@@ -74,7 +74,7 @@
<label>{{ $t('admin_settings.others.google_analytics') }}:</label>
<ValidationProvider tag="div" mode="passive" class="input-wrapper" name="Google Analytics Code"
v-slot="{ errors }">
<input @input="$updateText('/admin/settings', 'google_analytics', app.googleAnalytics)" v-model="app.googleAnalytics"
<input @input="$updateText('/admin/settings', 'google_analytics', app.googleAnalytics, true)" v-model="app.googleAnalytics"
:placeholder="$t('admin_settings.others.google_analytics_plac')"
type="text" :class="{'is-error': errors[0]}" class="focus-border-theme"/>
<span class="error-message" v-if="errors[0]">{{ errors[0] }}</span>
@@ -84,7 +84,7 @@
<div class="block-wrapper">
<label>{{ $t('admin_settings.others.mimetypes_blacklist') }}:</label>
<ValidationProvider tag="div" mode="passive" class="input-wrapper" name="Mimetypes Blacklist" v-slot="{ errors }">
<textarea rows="2" @input="$updateText('/admin/settings', 'mimetypes_blacklist', app.mimetypesBlacklist)" v-model="app.mimetypesBlacklist" :placeholder="$t('admin_settings.others.mimetypes_blacklist_plac')" type="text" :class="{'is-error': errors[0]}" class="focus-border-theme"/>
<textarea rows="2" @input="$updateText('/admin/settings', 'mimetypes_blacklist', app.mimetypesBlacklist, true)" v-model="app.mimetypesBlacklist" :placeholder="$t('admin_settings.others.mimetypes_blacklist_plac')" type="text" :class="{'is-error': errors[0]}" class="focus-border-theme"/>
<span class="error-message" v-if="errors[0]">{{ errors[0] }}</span>
</ValidationProvider>
<small class="input-help" v-html="$t('admin_settings.others.mimetypes_blacklist_help')"></small>
@@ -93,7 +93,7 @@
<div class="block-wrapper">
<label>{{ $t('admin_settings.others.upload_limit') }}:</label>
<ValidationProvider tag="div" mode="passive" class="input-wrapper" name="Upload Limit" v-slot="{ errors }">
<input @input="$updateText('/admin/settings', 'upload_limit', app.uploadLimit)" v-model="app.uploadLimit" :placeholder="$t('admin_settings.others.upload_limit_plac')" type="number" min="0" step="1" :class="{'is-error': errors[0]}" class="focus-border-theme"/>
<input @input="$updateText('/admin/settings', 'upload_limit', app.uploadLimit, true)" v-model="app.uploadLimit" :placeholder="$t('admin_settings.others.upload_limit_plac')" type="number" min="0" step="1" :class="{'is-error': errors[0]}" class="focus-border-theme"/>
<span class="error-message" v-if="errors[0]">{{ errors[0] }}</span>
</ValidationProvider>
<small class="input-help" v-html="$t('admin_settings.others.upload_limit_help')"></small>