Add gallery argument to /imagine command (#5168)
* Add gallery argument to /imagine to skip character gallery save Adds a `gallery` named argument (default: true) to the /imagine slash command. When `gallery=false`, the generated image is saved to the generic images directory instead of the character-specific gallery folder, while still returning a usable image URL. This is useful for extensions that manage their own image display (e.g. inline in chat messages) and don't need gallery copies. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Can't assign to a constant * Update help string to clarify image saving behavior in generation requests * Fix file name template if no char name provided --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
This commit is contained in:
@@ -2952,7 +2952,7 @@ async function generatePicture(initiator, args, trigger, message, callback) {
|
||||
const quietPrompt = getQuietPrompt(generationType, trigger);
|
||||
const context = getContext();
|
||||
|
||||
const characterName = context.groupId
|
||||
let characterName = context.groupId
|
||||
? context.groups[Object.keys(context.groups).filter(x => context.groups[x].id === context.groupId)[0]]?.id?.toString()
|
||||
: context.characters[context.characterId]?.name;
|
||||
|
||||
@@ -2974,6 +2974,10 @@ async function generatePicture(initiator, args, trigger, message, callback) {
|
||||
callback = () => { };
|
||||
}
|
||||
|
||||
if (isFalseBoolean(args?.gallery)) {
|
||||
characterName = '';
|
||||
}
|
||||
|
||||
const dimensions = setTypeSpecificDimensions(generationType);
|
||||
const abortController = new AbortController();
|
||||
const stopButton = document.getElementById('sd_stop_gen');
|
||||
@@ -3366,7 +3370,7 @@ async function sendGenerationRequest(generationType, prompt, additionalNegativeP
|
||||
return;
|
||||
}
|
||||
|
||||
const filename = `${characterName}_${humanizedDateTime()}`;
|
||||
const filename = characterName ? `${characterName}_${humanizedDateTime()}` : humanizedDateTime();
|
||||
const base64Image = await saveBase64AsFile(result.data, characterName, filename, result.format);
|
||||
callback
|
||||
? await callback(prompt, base64Image, generationType, additionalNegativePrefix, initiator, prefixedPrompt, result.format)
|
||||
@@ -5372,6 +5376,9 @@ jQuery(async () => {
|
||||
new SlashCommandNamedArgument(
|
||||
'quiet', 'whether to post the generated image to chat', [ARGUMENT_TYPE.BOOLEAN], false, false, 'false',
|
||||
),
|
||||
new SlashCommandNamedArgument(
|
||||
'gallery', 'whether to save the generated image to the character gallery', [ARGUMENT_TYPE.BOOLEAN], false, false, 'true',
|
||||
),
|
||||
SlashCommandNamedArgument.fromProps({
|
||||
name: 'negative',
|
||||
description: 'negative prompt prefix',
|
||||
@@ -5554,7 +5561,7 @@ jQuery(async () => {
|
||||
],
|
||||
helpString: `
|
||||
<div>
|
||||
Requests to generate an image and posts it to chat (unless <code>quiet=true</code> argument is specified).
|
||||
Requests to generate an image and posts it to chat (unless <code>quiet=true</code> argument is specified). The image is saved to the character gallery by default; use <code>gallery=false</code> to save to the root of the user images directory.
|
||||
</div>
|
||||
<div>
|
||||
Supported arguments: <code>${Object.values(triggerWords).flat().join(', ')}</code>.
|
||||
|
||||
Reference in New Issue
Block a user