Skip to content

Commit

Permalink
Fix #1705: Corrections to image resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed May 13, 2021
1 parent d407e6d commit 11ad7a1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Change Log: `bootstrap-fileinput`

**Date**: _under development_

- (enh #1705): Corrections to image resizing.
- (enh #1704): Enhance and fix CDN to use jsDelivr.

## version 5.2.0
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "5.1.x-dev"
"dev-master": "5.2.x-dev"
}
}
}
16 changes: 11 additions & 5 deletions js/fileinput.js
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@
case 'minFileSize':
case 'maxFileSize':
case 'maxFilePreviewSize':
case 'resizeImageQuality':
case 'resizeQuality':
case 'resizeIfSizeMoreThan':
case 'progressUploadThreshold':
case 'initialPreviewCount':
Expand Down Expand Up @@ -3158,8 +3158,8 @@
},
_resetCanvas: function () {
var self = this;
if (self.canvas && self.imageCanvasContext) {
self.imageCanvasContext.clearRect(0, 0, self.canvas.width, self.canvas.height);
if (self.imageCanvas && self.imageCanvasContext) {
self.imageCanvasContext.clearRect(0, 0, self.imageCanvas.width, self.imageCanvas.height);
}
},
_hasInitialPreview: function () {
Expand Down Expand Up @@ -5272,7 +5272,7 @@
fileExtExpr = '', previewData = $h.createObjectURL(file), fileCount = 0,
strTypes = '', fileId, canLoad, fileReaderAborted = false,
func, knownTypes = 0, isImage, txtFlag, processFileLoaded = function () {
var msg = msgProgress.setTokens({
var isImageResized = !!fm.loadedImages[id], msg = msgProgress.setTokens({
'index': i + 1,
'files': numFiles,
'percent': 50,
Expand All @@ -5284,7 +5284,13 @@
readFile(i + 1);
}, self.processDelay);
if (self._raise('fileloaded', [file, previewId, id, i, reader]) && self.isAjaxUpload) {
fm.add(file);
if (!isImageResized) {
fm.add(file);
}
} else {
if (isImageResized) {
fm.removeFile(id);
}
}
};
if (!file) {
Expand Down
8 changes: 4 additions & 4 deletions js/fileinput.min.js

Large diffs are not rendered by default.

0 comments on commit 11ad7a1

Please sign in to comment.