Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

refactor(gallery): expose one public image-URL accessor

joshistoast1379ed362979
diff --git a/invokeai/frontend/webv2/src/features/gallery/data/backend.ts b/invokeai/frontend/webv2/src/features/gallery/data/backend.ts
index bdd32bec38..11aca3d475 100644
--- a/invokeai/frontend/webv2/src/features/gallery/data/backend.ts
+++ b/invokeai/frontend/webv2/src/features/gallery/data/backend.ts
@@ -8,7 +8,7 @@ import type {
GalleryView,
} from '@features/gallery/core/types';
-import { getGalleryImageFullUrl, getGalleryImageThumbnailUrl } from '@features/gallery/core/imageUrls';
+import { getGalleryImageThumbnailUrl } from '@features/gallery/core/imageUrls';
import { absolutizeApiUrl, apiFetch, apiFetchJson, apiFetchRaw, sleep } from '@platform/transport/http';
interface BackendBoardDTO {
@@ -56,11 +56,6 @@ interface ListImagesResponse {
const imageCategories = ['general'];
const assetCategories = ['control', 'mask', 'user', 'other'];
-export const getImageThumbnailUrl = getGalleryImageThumbnailUrl;
-
-/** The full-resolution image URL for an image referenced only by name (e.g. a v2 canvas layer's `CanvasImageRef`). */
-export const getImageFullUrl = getGalleryImageFullUrl;
-
const toSearchParams = (entries: Record<string, boolean | number | string | string[] | undefined>): string => {
const params = new URLSearchParams();
@@ -86,7 +81,7 @@ const mapBoard = (board: BackendBoardDTO): GalleryBoard => ({
archived: board.archived,
assetCount: board.asset_count,
coverImageName: board.cover_image_name,
- coverThumbnailUrl: board.cover_image_name ? getImageThumbnailUrl(board.cover_image_name) : undefined,
+ coverThumbnailUrl: board.cover_image_name ? getGalleryImageThumbnailUrl(board.cover_image_name) : undefined,
id: board.board_id,
imageCount: board.image_count,
kind: 'board',
@@ -178,7 +173,7 @@ export const listGalleryDateBoards = async (): Promise<GalleryBoard[]> => {
archived: false,
assetCount: board.asset_count,
coverImageName: board.cover_image_name,
- coverThumbnailUrl: board.cover_image_name ? getImageThumbnailUrl(board.cover_image_name) : undefined,
+ coverThumbnailUrl: board.cover_image_name ? getGalleryImageThumbnailUrl(board.cover_image_name) : undefined,
id: board.virtual_board_id,
imageCount: board.image_count,
kind: 'date',
diff --git a/invokeai/frontend/webv2/src/features/gallery/index.ts b/invokeai/frontend/webv2/src/features/gallery/index.ts
index 32c8a06e9f..b4f088edd4 100644
--- a/invokeai/frontend/webv2/src/features/gallery/index.ts
+++ b/invokeai/frontend/webv2/src/features/gallery/index.ts
@@ -16,8 +16,6 @@ import {
getGalleryImageByName,
getGalleryImageMetadata,
getGalleryImagesByNames,
- getImageFullUrl,
- getImageThumbnailUrl,
isDateBoardId,
listGalleryBoards,
makeImageDurable,
@@ -30,11 +28,9 @@ import {
/** Resolve backend Gallery images without exposing transport DTOs or endpoints. */
export const galleryImages = {
- fullUrl: getImageFullUrl,
metadata: getGalleryImageMetadata,
resolve: getGalleryImageByName,
resolveMany: getGalleryImagesByNames,
- thumbnailUrl: getImageThumbnailUrl,
} as const;
/** Import/export intents shared by image-producing and image-consuming features. */
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/StagingBar.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/StagingBar.tsx
index 32db403f2a..1fe1520218 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/StagingBar.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/StagingBar.tsx
@@ -14,7 +14,8 @@ import {
Stack,
Text,
} from '@chakra-ui/react';
-import { galleryDurability, galleryImages } from '@features/gallery';
+import { galleryDurability } from '@features/gallery';
+import { galleryImageUrls } from '@features/gallery/utility';
import { useQueueItemProgress, useQueueItemProgressImage } from '@features/queue/react';
import { Button, IconButton, MenuContent, toaster, Tooltip } from '@platform/ui';
import { StreamingImageFrame } from '@platform/ui/streaming-image/StreamingImageFrame';
@@ -357,7 +358,7 @@ const StagingThumbnail = ({
{slot.kind === 'candidate' ? (
<img
alt={slot.candidate.imageName}
- src={slot.candidate.thumbnailUrl || galleryImages.thumbnailUrl(slot.candidate.imageName)}
+ src={slot.candidate.thumbnailUrl || galleryImageUrls.thumbnail(slot.candidate.imageName)}
style={{ display: 'block', height: '100%', objectFit: 'cover', width: '100%' }}
/>
) : (
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerThumbnail.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerThumbnail.tsx
index 7c4c691977..9a3e74fd43 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerThumbnail.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerThumbnail.tsx
@@ -8,7 +8,7 @@ import type {
import type { CSSProperties } from 'react';
import { Box, Icon, IconButton } from '@chakra-ui/react';
-import { galleryImages } from '@features/gallery';
+import { galleryImageUrls } from '@features/gallery/utility';
import {
getLayerThumbnailFallbackRenderState,
nextLayerThumbnailFallbackStage,
@@ -85,8 +85,8 @@ const LayerThumbnailContent = ({
const fallbackUrl =
fallbackImage && fallbackStage !== 'failed'
? fallbackStage === 'thumbnail'
- ? galleryImages.thumbnailUrl(fallbackImage.imageName)
- : galleryImages.fullUrl(fallbackImage.imageName)
+ ? galleryImageUrls.thumbnail(fallbackImage.imageName)
+ : galleryImageUrls.full(fallbackImage.imageName)
: null;
const { showFallback, showRetry } = getLayerThumbnailFallbackRenderState(drawn, fallbackStage, status === 'error');