Skip to content

Media aware buttons and registry#1336

Open
kalebbroo wants to merge 5 commits intomcmonkeyprojects:masterfrom
kalebbroo:media-aware-buttons
Open

Media aware buttons and registry#1336
kalebbroo wants to merge 5 commits intomcmonkeyprojects:masterfrom
kalebbroo:media-aware-buttons

Conversation

@kalebbroo
Copy link
Copy Markdown
Contributor

Extension friendly media button registry

  • Added registerMediaButton(name, action, title, mediaTypes, isDefault) API that lets extensions register custom buttons with media type filtering. Extensions can specify which media types their button applies to (e.g. ['audio'], ['image'], ['video'], or null for all). Registered buttons with isDefault: true are promoted to the visible button bar (vs hidden in "More" dropdown) when the user hasn't customized their button list.
    Media type awareness for built in buttons
  • Image only buttons (Use As Init, Use As Image Prompt, Edit Image, Upscale 2x, Refine Image) are now hidden when viewing audio or video files. Both the main button bar and the "More" dropdown respect mediaTypes filtering.
    Output history integration
  • Registered media buttons also appear in the context menu for items in the output history panel.
    Utility addition
  • Added getMediaType(src) helper in util.js that returns 'video', 'audio', or 'image' based on file extension.

- Introduce a registerMediaButton API to allow extensions to add buttons for images/audio/video (name, action, title, mediaTypes, isDefault).
- Add media type awareness (getMediaType) and filter buttons by mediaTypes so image only actions won't appear for audio/video.
- Ensure registered default buttons are merged into the visible default set and that registered buttons show up in output history.

/** Registers a media button for extensions. 'mediaTypes' filters by type eg ['audio'], null means all. 'isDefault' promotes to visible (vs More dropdown). */
function registerMediaButton(name, action, title = '', mediaTypes = null, isDefault = false) {
if (!name || typeof name != 'string') {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are not needed

[ConfigComment("A list of what buttons to include directly under images in the main prompt area of the Generate tab.\nOther buttons will be moved into the 'More' dropdown.\nThis should be a comma separated list."
+ "\nThe following options are available: \"Use As Init\", \"Use As Image Prompt\", \"Edit Image\", \"Upscale 2x\", \"Star\", \"Reuse Parameters\", \"Open In Folder\", \"Delete\", \"Download\" \"View In History\", \"Refine Image\", \"Copy Path\""
+ "\nThe following options are available: \"Use As Init\", \"Use As Image Prompt\", \"Edit Image\", \"Upscale 2x\", \"Star\", \"Reuse Parameters\", \"Open In Folder\", \"Delete\", \"Download\", \"View In History\", \"Refine Image\", \"Copy Path\", \"Copy Raw Metadata\""
+ "\nButtons like 'Edit Image' or 'Upscale 2x' only apply to images and will not show for audio or video files."
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\nSome buttons like 'Edit Image' may only apply (...)

});
}));
}, '', 'Runs an instant generation with Refine / Upscale turned on');
}, '', 'Runs an instant generation with Refine / Upscale turned on', ['image']);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no

mainGenHandler.doGenerate(input_overrides, { 'initimagecreativity': 0.4 });
}));
}, '', 'Runs an instant generation with this image as the input and scale doubled');
}, '', 'Runs an instant generation with this image as the input and scale doubled', ['image']);
Copy link
Copy Markdown
Member

@mcmonkey4eva mcmonkey4eva Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image & video

}
}
}, '', 'Sets this image as the Init Image parameter input');
}, '', 'Sets this image as the Init Image parameter input', ['image']);
Copy link
Copy Markdown
Member

@mcmonkey4eva mcmonkey4eva Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image & video

}
});
}
for (let reg of registeredMediaButtons) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably a lot of buttons do not want to be in the general set (this appears for example in the History menu), should either be current image only, or have a boolean split for where these appear

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the bool so extension devs can choose.

}
let isVideo = isVideoExt(src);
let isAudio = isAudioExt(src);
let mediaType = isVideo ? 'video' : (isAudio ? 'audio' : 'image');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you added getMediaType but you're not using it here?

- An optional showInHistory parameter to registerMediaButton (default true) so extensions can control whether a media button appears in the History panel.
- Adjust outputhistory to respect this flag when building button lists.
- Use getMediaType for media detection in setCurrentImage and expand media type allowances for some built in buttons (e.g. 'Use As Init' and 'Upscale 2x' now include video; 'Refine Image' no longer restricts by mediaTypes).
- Also simplify the registration call (validation removed) and make a small wording tweak in Settings comments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants