Added button in settings to correct preview image extensions.

- Civitai in the past and present sends incorrect image extension information. (content type? content disposition?)
This commit is contained in:
Christian Bastian
2024-07-24 16:43:11 -04:00
parent 3ca0f500b2
commit d17cb5d93a
3 changed files with 89 additions and 1 deletions

View File

@@ -628,6 +628,7 @@
.model-manager .tag-generator-settings > div {
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: center;
gap: 8px;
margin: 16px 0;
@@ -635,7 +636,7 @@
.model-manager .model-manager-settings button {
height: 40px;
width: 120px;
min-width: 120px;
justify-content: center;
}

View File

@@ -3680,6 +3680,32 @@ class SettingsView {
}).element;
this.elements.saveButton = saveButton;
const correctPreviewsButton = new ComfyButton({
content: "Fix Preview Extensions",
tooltip: "Correct image extensions in all model directories",
action: async(e) => {
const [button, icon, span] = comfyButtonDisambiguate(e.target);
button.disabled = true;
const data = await request(
"/model-manager/preview/correct-extensions")
.catch((err) => {
return { "success": false };
});
const success = data["success"];
if (success) {
const detectPlural = data["detected"] === 1 ? "" : "s";
const correctPlural = data["corrected"] === 1 ? "" : "s";
const message = `Detected ${data["detected"]} extension${detectPlural}.\nCorrected ${data["corrected"]} extension${correctPlural}.`;
window.alert(message);
}
comfyButtonAlert(e.target, success);
if (data["corrected"] > 0) {
await this.reload(true);
}
button.disabled = false;
},
}).element;
$el("div.model-manager-settings", {
$: (el) => (this.element = el),
}, [
@@ -3822,6 +3848,10 @@ class SettingsView {
min: 1,
}),
]),
$el("h2", ["Preview"]),
$el("div", [
correctPreviewsButton,
]),
]);
}
}