Skip to content

Commit aff4b0d

Browse files
committed
Fix #1780: Correct autoReplace behavior to clear already uploaded thumbnails
1 parent c6077dc commit aff4b0d

File tree

5 files changed

+53
-43
lines changed

5 files changed

+53
-43
lines changed

CHANGE.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ Change Log: `bootstrap-fileinput`
33

44
## version 5.2.8
55

6-
**Date**: _under development_
6+
**Date**: 10-May-2022
77

88
- (enh #1787): Enhance image size validation messages.
99
- (enh #1786): Correct Uzbek Cyrillic Translation file name.
1010
- (enh #1784): Correct documentation for `layoutTemplates.fileIcon`.
1111
- (bug #1783): Correct image size validation checks (for min and max width/height).
1212
- (enh #1782): Correct loading indicator reset for file selection.
13+
- (bug #1780): Correct `autoReplace` behavior to clear already uploaded thumbnails.
1314
- (enh #1779): New plugin method `showUserError` and new event `fileusererror`.
1415
Usage:
1516
```js

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -92,34 +92,34 @@ Step 1: Load the following assets on your page in the order mentioned.
9292
<!-- link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css" crossorigin="anonymous" -->
9393

9494
<!-- the fileinput plugin styling CSS file -->
95-
<link href="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].7/css/fileinput.min.css" media="all" rel="stylesheet" type="text/css" />
95+
<link href="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].8/css/fileinput.min.css" media="all" rel="stylesheet" type="text/css" />
9696

9797
<!-- if using RTL (Right-To-Left) orientation, load the RTL CSS file after fileinput.css by uncommenting below -->
98-
<!-- link href="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].7/css/fileinput-rtl.min.css" media="all" rel="stylesheet" type="text/css" /-->
98+
<!-- link href="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].8/css/fileinput-rtl.min.css" media="all" rel="stylesheet" type="text/css" /-->
9999

100100
<!-- the jQuery Library -->
101101
<script src="https://code.jquery.com/jquery-3.6.0.min.js" crossorigin="anonymous"></script>
102102

103103
<!-- piexif.min.js is needed for auto orienting image files OR when restoring exif data in resized images and when you
104104
wish to resize images before upload. This must be loaded before fileinput.min.js -->
105-
<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].7/js/plugins/piexif.min.js" type="text/javascript"></script>
105+
<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].8/js/plugins/piexif.min.js" type="text/javascript"></script>
106106

107107
<!-- sortable.min.js is only needed if you wish to sort / rearrange files in initial preview.
108108
This must be loaded before fileinput.min.js -->
109-
<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].7/js/plugins/sortable.min.js" type="text/javascript"></script>
109+
<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].8/js/plugins/sortable.min.js" type="text/javascript"></script>
110110

111111
<!-- bootstrap.bundle.min.js below is needed if you wish to zoom and preview file content in a detail modal
112112
dialog. bootstrap 5.x or 4.x is supported. You can also use the bootstrap js 3.3.x versions. -->
113113
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
114114

115115
<!-- the main fileinput plugin script JS file -->
116-
<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].7/js/fileinput.min.js"></script>
116+
<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].8/js/fileinput.min.js"></script>
117117

118118
<!-- following theme script is needed to use the Font Awesome 5.x theme (`fas`). Uncomment if needed. -->
119-
<!-- script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].7/themes/fas/theme.min.js"></script -->
119+
<!-- script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].8/themes/fas/theme.min.js"></script -->
120120

121121
<!-- optionally if you need translation for your language then include the locale file as mentioned below (replace LANG.js with your language locale) -->
122-
<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].7/js/locales/LANG.js"></script>
122+
<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected].8/js/locales/LANG.js"></script>
123123
```
124124
With v5.2.1, the plugin is able to automatically detect the bootstrap library version and deliver the relevant bootstrap specific functionality (if you have loaded the bootstrap.min.js before fileinput.min.js). In case of any issues - you can explicitly set the bootstrap version by setting the following variable before the plugin initialization script.
125125

composer.json

+33-33
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
{
2-
"name": "kartik-v/bootstrap-fileinput",
3-
"description": "An enhanced HTML 5 file input for Bootstrap 5.x, 4.x, and 3.x with features for file preview for many file types, multiple selection, ajax uploads, and more.",
4-
"keywords": [
5-
"bootstrap",
6-
"jquery",
7-
"file",
8-
"input",
9-
"preview",
10-
"upload",
11-
"image",
12-
"multiple",
13-
"ajax",
14-
"delete",
15-
"progress"
16-
],
17-
"homepage": "https://github.com/kartik-v/bootstrap-fileinput",
18-
"license": "BSD-3-Clause",
19-
"authors": [
20-
{
21-
"name": "Kartik Visweswaran",
22-
"email": "[email protected]",
23-
"homepage": "http://www.krajee.com/"
24-
}
25-
],
26-
"autoload": {
27-
"psr-4": {
28-
"kartik\\plugins\\fileinput\\": ""
29-
}
30-
},
31-
"extra": {
32-
"branch-alias": {
33-
"dev-master": "5.2.x-dev"
34-
}
2+
"name": "kartik-v/bootstrap-fileinput",
3+
"description": "An enhanced HTML 5 file input for Bootstrap 5.x, 4.x, and 3.x with features for file preview for many file types, multiple selection, ajax uploads, and more.",
4+
"keywords": [
5+
"bootstrap",
6+
"jquery",
7+
"file",
8+
"input",
9+
"preview",
10+
"upload",
11+
"image",
12+
"multiple",
13+
"ajax",
14+
"delete",
15+
"progress"
16+
],
17+
"homepage": "https://github.com/kartik-v/bootstrap-fileinput",
18+
"license": "BSD-3-Clause",
19+
"authors": [
20+
{
21+
"name": "Kartik Visweswaran",
22+
"email": "[email protected]",
23+
"homepage": "http://www.krajee.com/"
3524
}
25+
],
26+
"autoload": {
27+
"psr-4": {
28+
"kartik\\plugins\\fileinput\\": ""
29+
}
30+
},
31+
"extra": {
32+
"branch-alias": {
33+
"dev-master": "5.2.x-dev"
34+
}
35+
}
3636
}

js/fileinput.js

+9
Original file line numberDiff line numberDiff line change
@@ -5195,6 +5195,7 @@
51955195
if (total > maxCount) {
51965196
self._resetPreviewThumbs(isAjaxUpload);
51975197
}
5198+
51985199
} else {
51995200
if (inclAll) {
52005201
total = self._getFileCount(initCount, true);
@@ -5219,6 +5220,14 @@
52195220
}
52205221
}
52215222
}
5223+
if (self.autoReplace) {
5224+
self._getThumbs().each(function() {
5225+
var $thumb = $(this);
5226+
if ($thumb.hasClass('file-preview-success') || $thumb.hasClass('file-preview-error')) {
5227+
$thumb.remove();
5228+
}
5229+
});
5230+
}
52225231
self.readFiles(tfiles);
52235232
self._toggleLoading('hide');
52245233
},

js/fileinput.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)