MCPcopy Create free account
hub / github.com/error311/FileRise / displayFilePreview

Function displayFilePreview

public/js/filePreview.js:1109–1129  ·  view source on GitHub ↗
(file, container)

Source from the content-addressed store, hash-verified

1107
1108/* -------------------------------- Small display helper -------------------------------- */
1109export function displayFilePreview(file, container) {
1110 const actualFile = file.file || file;
1111 if (!(actualFile instanceof File)) {
1112 console.error("displayFilePreview called with an invalid file object");
1113 return;
1114 }
1115 container.style.display = "inline-block";
1116 while (container.firstChild) container.removeChild(container.firstChild);
1117
1118 if (IMG_RE.test(actualFile.name)) {
1119 const img = document.createElement("img");
1120 img.src = URL.createObjectURL(actualFile);
1121 img.classList.add("file-preview-img");
1122 container.appendChild(img);
1123 } else {
1124 const iconSpan = document.createElement("span");
1125 iconSpan.classList.add("material-icons", "file-icon");
1126 iconSpan.textContent = "insert_drive_file";
1127 container.appendChild(iconSpan);
1128 }
1129}
1130
1131// expose for HTML onclick usage
1132window.previewFile = previewFile;

Callers 3

updateFileInfoCountFunction · 0.85
createFileEntryFunction · 0.85
processFilesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected