Fix: Make image_data a visible widget and remove alert messages

Changes:
- Moved image_data from optional to required (no forceInput)
- image_data is now a multiline STRING widget (auto-filled by file picker)
- Removed alert() and console.log() messages
- Store base64 data in both node.properties and widget.value

This fixes the 'object supporting the buffer API required' error
by ensuring image_data widget exists and can be set by JavaScript.
This commit is contained in:
solidlime
2026-01-07 21:37:33 +09:00
parent b5f185447d
commit 12cd33bbc8
2 changed files with 8 additions and 12 deletions
+1 -3
View File
@@ -52,12 +52,10 @@ class RandomImagePicker:
"max": 0xffffffffffffffff,
"tooltip": "Random seed for reproducible selection in Folder mode"
}),
},
"optional": {
"image_data": ("STRING", {
"default": "",
"multiline": True,
"forceInput": True,
"tooltip": "Base64 image data from file picker (auto-filled)"
}),
}
}
+7 -9
View File
@@ -25,7 +25,6 @@ app.registerExtension({
const folderModeWidget = node.widgets.find(w => w.name === "folder_mode");
if (folderModeWidget) {
folderModeWidget.value = false;
console.log("[Random Image Picker] Switched to Single mode");
}
// Read file as base64
@@ -33,18 +32,17 @@ app.registerExtension({
reader.onload = (event) => {
const base64Data = event.target.result;
// Find or create the image_data widget
// Store image_data in node properties
if (!node.properties) {
node.properties = {};
}
node.properties.image_data = base64Data;
// Also try to set widget if it exists
let imageDataWidget = node.widgets.find(w => w.name === "image_data");
if (imageDataWidget) {
imageDataWidget.value = base64Data;
}
console.log(`[Random Image Picker] File loaded: ${file.name} (${(base64Data.length / 1024).toFixed(2)} KB)`);
alert(`✅ Image loaded successfully!\n\nFile: ${file.name}\nSize: ${(file.size / 1024).toFixed(2)} KB\n\nMode: Automatically switched to Single\n\nYou can now run the workflow.`);
};
reader.onerror = () => {
alert("❌ Failed to read the image file.\n\nPlease try again.");
};
reader.readAsDataURL(file);