Skip to content

Commit

Permalink
feat: move max avatar size into config, refactor image uploader code
Browse files Browse the repository at this point in the history
  • Loading branch information
akinsey committed Sep 27, 2021
1 parent 4c5b781 commit 8419b23
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
1 change: 1 addition & 0 deletions public/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ window.websocket_host = 'localhost'
window.websocket_port = '23958'
window.post_max_length = 10000
window.max_image_size = 10485760
window.max_avatar_size = 102400
window.portal = { enabled: false }
window.currentYear = new Date().getFullYear()
// window.GAKey = config.gaKey
Expand Down
16 changes: 4 additions & 12 deletions src/components/images/ImageUploader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,21 @@ export default {
let files = e.target.files || e.dataTransfer.files
if (!files.length) return
console.log(e.target.files)
let images = []
for (var i = 0; i < files.length; i++) {
for (let i = 0; i < files.length; i++) {
let file = files[i]
if (!file.type.match(/image.*/)) continue
images.push(file)
}
console.log(props.purpose)
if (props.purpose === 'avatar' || props.purpose === 'logo' || props.purpose === 'favicon') { images = [images[0]] }
console.log(images)
if (images.length > 0) {
// if (v.fileInput.files.length > 10) {
// return $timeout(function() { Alert.error('Error: Exceeded 10 images.'); });
// }
if (images.length > 10) return handleError('Error: Exceeded 10 images.')
else if (images.length > 0) {
// (re)prime loading and progress variables
v.imagesUploading = true
// let imagesProgress = 0
// let imagesProgressSum = 0
let errImages = []
let maxImageSize = props.purpose === 'avatar' ? 102400 : 10485760 // TODO(akinsey): forumData.max_image_size;
/**
* Image = {
* name: {string} The filename of the string (provided by host computer),
Expand Down Expand Up @@ -215,6 +206,7 @@ export default {
imagesProgress: 0,
imagesProgressSum: 0,
uploadingImages: 0,
maxImageSize: props.purpose === 'avatar' ? window.max_avatar_size : window.max_image_size,
warningMsg: '',
model: null,
status: null
Expand Down

0 comments on commit 8419b23

Please sign in to comment.