Untitled
unknown
plain_text
3 years ago
1.2 kB
31
Indexable
$(document).ready(function() {
$(function() {
function imagesPreview(input, placeToInsertImagePreview, callback) {
if (input.files) {
var filesAmount = input.files.length;
for (i = 0; i < filesAmount; i++) {
var reader = new FileReader();
reader.onload = function(event) {
$($.parseHTML('<img class="preview__thumb">')).attr('src', event.target.result).appendTo(placeToInsertImagePreview);
};
reader.readAsDataURL(input.files[i]);
}
if (typeof callback === 'function') {
callback();
}
}
}
$('#file__input').on('change', function() {
imagesPreview(this, '#the__gallery', function() {
setTimeout(function() {
var count = $('.preview__thumb').length;
console.log('Count:', count);
// You can apply your custom styles based on the count here
}, 100); // Add a delay of 100ms before calling the counting function
});
});
});
});
Editor is loading...