mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-30 04:50:04 +00:00
Add support for image_folder field in node image input spec (#2509)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { ComfyNodeDef } from '@/types/apiTypes'
|
||||
import { ComfyNodeDef, InputSpec } from '@/types/apiTypes'
|
||||
|
||||
import { app } from '../../scripts/app'
|
||||
|
||||
@@ -7,8 +7,16 @@ import { app } from '../../scripts/app'
|
||||
app.registerExtension({
|
||||
name: 'Comfy.UploadImage',
|
||||
beforeRegisterNodeDef(nodeType, nodeData: ComfyNodeDef) {
|
||||
if (nodeData?.input?.required?.image?.[1]?.image_upload === true) {
|
||||
nodeData.input.required.upload = ['IMAGEUPLOAD']
|
||||
// Check if there is a required input named 'image' in the nodeData
|
||||
const imageInputSpec: InputSpec | undefined =
|
||||
nodeData?.input?.required?.image
|
||||
|
||||
// Get the config from the image input spec if it exists
|
||||
const config = imageInputSpec?.[1] ?? {}
|
||||
const { image_upload = false, image_folder = 'input' } = config
|
||||
|
||||
if (image_upload && nodeData?.input?.required) {
|
||||
nodeData.input.required.upload = ['IMAGEUPLOAD', { image_folder }]
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -433,6 +433,7 @@ export const ComfyWidgets: Record<string, ComfyWidgetConstructor> = {
|
||||
(w) => w.name === (inputData[1]?.widget ?? 'image')
|
||||
) as IStringWidget
|
||||
let uploadWidget
|
||||
const { image_folder = 'input' } = inputData[1] ?? {}
|
||||
|
||||
function showImage(name) {
|
||||
const img = new Image()
|
||||
@@ -447,7 +448,7 @@ export const ComfyWidgets: Record<string, ComfyWidgetConstructor> = {
|
||||
name = name.substring(folder_separator + 1)
|
||||
}
|
||||
img.src = api.apiURL(
|
||||
`/view?filename=${encodeURIComponent(name)}&type=input&subfolder=${subfolder}${app.getPreviewFormatParam()}${app.getRandParam()}`
|
||||
`/view?filename=${encodeURIComponent(name)}&type=${image_folder}&subfolder=${subfolder}${app.getPreviewFormatParam()}${app.getRandParam()}`
|
||||
)
|
||||
node.setSizeForImage?.()
|
||||
}
|
||||
|
||||
@@ -344,6 +344,7 @@ const zStringInputSpec = inputSpec([
|
||||
const zComboInputProps = zBaseInputSpecValue.extend({
|
||||
control_after_generate: z.boolean().optional(),
|
||||
image_upload: z.boolean().optional(),
|
||||
image_folder: z.enum(['input', 'output', 'temp']).optional(),
|
||||
remote: zRemoteWidgetConfig.optional()
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user