thumb fix 3
This commit is contained in:
@@ -214,11 +214,39 @@
|
||||
return (bytes / 1048576).toFixed(1) + ' MB';
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', addBrowseButtons);
|
||||
// Live image preview for software_images image_id selects
|
||||
function addImagePreviewListeners() {
|
||||
var selects = document.querySelectorAll('select[id*="image_id"]:not([data-preview-added])');
|
||||
selects.forEach(function(sel) {
|
||||
sel.setAttribute('data-preview-added', 'true');
|
||||
sel.addEventListener('change', function() {
|
||||
var hint = sel.closest('li').querySelector('.inline-hints');
|
||||
if (!hint) {
|
||||
// Create hint element if it doesn't exist
|
||||
hint = document.createElement('p');
|
||||
hint.className = 'inline-hints';
|
||||
sel.closest('li').appendChild(hint);
|
||||
}
|
||||
if (sel.value) {
|
||||
hint.innerHTML = '<img src="/api/image/' + sel.value + '" style="max-height:80px;max-width:160px;object-fit:contain;margin-top:6px;" />';
|
||||
} else {
|
||||
hint.innerHTML = '';
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
addBrowseButtons();
|
||||
addImagePreviewListeners();
|
||||
});
|
||||
|
||||
if (typeof jQuery !== 'undefined') {
|
||||
jQuery(document).on('has_many_add:after', function() {
|
||||
setTimeout(addBrowseButtons, 50);
|
||||
setTimeout(function() {
|
||||
addBrowseButtons();
|
||||
addImagePreviewListeners();
|
||||
}, 50);
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user