Media aware buttons and registry#1336
Open
kalebbroo wants to merge 5 commits intomcmonkeyprojects:masterfrom
Open
Media aware buttons and registry#1336kalebbroo wants to merge 5 commits intomcmonkeyprojects:masterfrom
kalebbroo wants to merge 5 commits intomcmonkeyprojects:masterfrom
Conversation
- 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.
mcmonkey4eva
reviewed
Apr 7, 2026
|
|
||
| /** 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') { |
mcmonkey4eva
reviewed
Apr 7, 2026
src/Core/Settings.cs
Outdated
| [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." |
Member
There was a problem hiding this comment.
\nSome buttons like 'Edit Image' may only apply (...)
mcmonkey4eva
reviewed
Apr 7, 2026
| }); | ||
| })); | ||
| }, '', 'Runs an instant generation with Refine / Upscale turned on'); | ||
| }, '', 'Runs an instant generation with Refine / Upscale turned on', ['image']); |
mcmonkey4eva
reviewed
Apr 7, 2026
| 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']); |
mcmonkey4eva
reviewed
Apr 7, 2026
| } | ||
| } | ||
| }, '', 'Sets this image as the Init Image parameter input'); | ||
| }, '', 'Sets this image as the Init Image parameter input', ['image']); |
mcmonkey4eva
reviewed
Apr 7, 2026
| } | ||
| }); | ||
| } | ||
| for (let reg of registeredMediaButtons) { |
Member
There was a problem hiding this comment.
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
Contributor
Author
There was a problem hiding this comment.
Added the bool so extension devs can choose.
mcmonkey4eva
reviewed
Apr 7, 2026
| } | ||
| let isVideo = isVideoExt(src); | ||
| let isAudio = isAudioExt(src); | ||
| let mediaType = isVideo ? 'video' : (isAudio ? 'audio' : 'image'); |
Member
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extension friendly media button registry
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'], ornullfor all). Registered buttons withisDefault: trueare 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
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 respectmediaTypesfiltering.Output history integration
Utility addition
getMediaType(src)helper inutil.jsthat returns'video','audio', or'image'based on file extension.