Browse Source

Fix #1079: Correct initial preview rendering when no `initialPreviewConfig` supplied

Kartik Visweswaran 7 years ago
parent
commit
94a5337c12
3 changed files with 6 additions and 2 deletions
  1. 1 0
      CHANGE.md
  2. 5 2
      js/fileinput.js
  3. 0 0
      js/fileinput.min.js

+ 1 - 0
CHANGE.md

@@ -7,6 +7,7 @@ Change Log: `bootstrap-fileinput`
 
 **_This release adds Bootstrap v4.x support._**
 
+- (bug #1079): Correct initial preview rendering when no `initialPreviewConfig` supplied.
 - (enh #1078): Correct markup during file validation errors (non-ajax mode).
 - (enh #1075): Enhance initial preview delete behavior (ensure `previewCache` splices deleted initial preview content items).
 - (enh #1073): Enhance `refresh` method to overwrite options.

+ 5 - 2
js/fileinput.js

@@ -899,10 +899,13 @@
                     return {content: html, caption: caption};
                 },
                 footer: function (i, isDisabled, size) {
-                    var data = self.previewCache.data;
-                    if (!data || !data.config || data.config.length === 0 || $h.isEmpty(data.config[i])) {
+                    var data = self.previewCache.data || {};
+                    if ($h.isEmpty(data.content)) {
                         return '';
                     }
+                    if ($h.isEmpty(data.config) || $h.isEmpty(data.config[i])) {
+                        data.config[i] = {};
+                    }
                     isDisabled = isDisabled === undefined ? true : isDisabled;
                     var config = data.config[i], caption = $h.ifSet('caption', config), a,
                         width = $h.ifSet('width', config, 'auto'), url = $h.ifSet('url', config, false),

File diff suppressed because it is too large
+ 0 - 0
js/fileinput.min.js


Some files were not shown because too many files changed in this diff