Skip to content

Commit 8419b23

Browse files
committed
feat: move max avatar size into config, refactor image uploader code
1 parent 4c5b781 commit 8419b23

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

public/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ window.websocket_host = 'localhost'
99
window.websocket_port = '23958'
1010
window.post_max_length = 10000
1111
window.max_image_size = 10485760
12+
window.max_avatar_size = 102400
1213
window.portal = { enabled: false }
1314
window.currentYear = new Date().getFullYear()
1415
// window.GAKey = config.gaKey

src/components/images/ImageUploader.vue

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,21 @@ export default {
2020
2121
let files = e.target.files || e.dataTransfer.files
2222
if (!files.length) return
23-
console.log(e.target.files)
2423
let images = []
25-
for (var i = 0; i < files.length; i++) {
24+
for (let i = 0; i < files.length; i++) {
2625
let file = files[i]
2726
if (!file.type.match(/image.*/)) continue
2827
images.push(file)
2928
}
30-
console.log(props.purpose)
3129
if (props.purpose === 'avatar' || props.purpose === 'logo' || props.purpose === 'favicon') { images = [images[0]] }
3230
33-
console.log(images)
34-
35-
if (images.length > 0) {
36-
// if (v.fileInput.files.length > 10) {
37-
// return $timeout(function() { Alert.error('Error: Exceeded 10 images.'); });
38-
// }
39-
31+
if (images.length > 10) return handleError('Error: Exceeded 10 images.')
32+
else if (images.length > 0) {
4033
// (re)prime loading and progress variables
4134
v.imagesUploading = true
4235
// let imagesProgress = 0
4336
// let imagesProgressSum = 0
4437
let errImages = []
45-
let maxImageSize = props.purpose === 'avatar' ? 102400 : 10485760 // TODO(akinsey): forumData.max_image_size;
46-
4738
/**
4839
* Image = {
4940
* name: {string} The filename of the string (provided by host computer),
@@ -215,6 +206,7 @@ export default {
215206
imagesProgress: 0,
216207
imagesProgressSum: 0,
217208
uploadingImages: 0,
209+
maxImageSize: props.purpose === 'avatar' ? window.max_avatar_size : window.max_image_size,
218210
warningMsg: '',
219211
model: null,
220212
status: null

0 commit comments

Comments
 (0)