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>

3a952293b48f2803d6973ae08cf7b4c5a1b33861

bal-spec <186531371+bal-spec@users.noreply.github.com>

Signed
1 files changed, +10 -3Ignore whitespace
public/scripts/extensions/stable-diffusion/index.js+10 -3
@@ -2952,7 +2952,7 @@ async function generatePicture(initiator, args, trigger, message, callback) {
29522952 const quietPrompt = getQuietPrompt(generationType, trigger);
29532953 const context = getContext();
29542954
29552955 constlet characterName = context.groupId
29562956 ? context.groups[Object.keys(context.groups).filter(x => context.groups[x].id === context.groupId)[0]]?.id?.toString()
29572957 : context.characters[context.characterId]?.name;
29582958
@@ -2974,6 +2974,10 @@ async function generatePicture(initiator, args, trigger, message, callback) {
29742974 callback = () => { };
29752975 }
29762976
2977+ if (isFalseBoolean(args?.gallery)) {
2978+ characterName = '';
2979+ }
2980+
29772981 const dimensions = setTypeSpecificDimensions(generationType);
29782982 const abortController = new AbortController();
29792983 const stopButton = document.getElementById('sd_stop_gen');
@@ -3366,7 +3370,7 @@ async function sendGenerationRequest(generationType, prompt, additionalNegativeP
33663370 return;
33673371 }
33683372
33693373 const filename = characterName ? `${characterName}_${humanizedDateTime()}` : humanizedDateTime();
33703374 const base64Image = await saveBase64AsFile(result.data, characterName, filename, result.format);
33713375 callback
33723376 ? await callback(prompt, base64Image, generationType, additionalNegativePrefix, initiator, prefixedPrompt, result.format)
@@ -5372,6 +5376,9 @@ jQuery(async () => {
53725376 new SlashCommandNamedArgument(
53735377 'quiet', 'whether to post the generated image to chat', [ARGUMENT_TYPE.BOOLEAN], false, false, 'false',
53745378 ),
5379+ new SlashCommandNamedArgument(
5380+ 'gallery', 'whether to save the generated image to the character gallery', [ARGUMENT_TYPE.BOOLEAN], false, false, 'true',
5381+ ),
53755382 SlashCommandNamedArgument.fromProps({
53765383 name: 'negative',
53775384 description: 'negative prompt prefix',
@@ -5554,7 +5561,7 @@ jQuery(async () => {
55545561 ],
55555562 helpString: `
55565563 <div>
55575564 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.
55585565 </div>
55595566 <div>
55605567 Supported arguments: <code>${Object.values(triggerWords).flat().join(', ')}</code>.