Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/extensions/core/imageCompare.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
import type { NodeOutputWith } from '@/schemas/apiSchema'
import { appendCloudResParam } from '@/platform/distribution/cloudPreviewUtil'
import { api } from '@/scripts/api'
import { app } from '@/scripts/app'
import { useExtensionService } from '@/services/extensionService'
Expand Down Expand Up @@ -29,7 +28,6 @@ useExtensionService().registerExtension({

const toUrl = (record: Record<string, string>) => {
const params = new URLSearchParams(record)
appendCloudResParam(params, record.filename)
return api.apiURL(`/view?${params}${rand}`)
}

Expand Down
3 changes: 2 additions & 1 deletion src/platform/assets/components/MediaImageTop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<script setup lang="ts">
import { useImage, whenever } from '@vueuse/core'

import { appendCloudResUrl } from '@/platform/distribution/cloudPreviewUtil'
import type { AssetMeta } from '../schemas/mediaAssetSchema'

const { asset } = defineProps<{
Expand All @@ -33,7 +34,7 @@ const emit = defineEmits<{
}>()

const { state, error, isReady } = useImage({
src: asset.src ?? '',
src: asset.src ? appendCloudResUrl(asset.src) : '',
alt: asset.display_name || asset.name
})

Expand Down
4 changes: 1 addition & 3 deletions src/platform/assets/composables/media/assetMappers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { AssetItem } from '@/platform/assets/schemas/assetSchema'
import type { OutputAssetMetadata } from '@/platform/assets/schemas/assetMetadataSchema'
import type { AssetContext } from '@/platform/assets/schemas/mediaAssetSchema'
import { appendCloudResParam } from '@/platform/distribution/cloudPreviewUtil'
import { api } from '@/scripts/api'
import type { ResultItemImpl, TaskItemImpl } from '@/stores/queueStore'

Expand Down Expand Up @@ -45,7 +44,7 @@ export function mapTaskOutputToAssetItem(
? new Date(taskItem.executionStartTimestamp).toISOString()
: new Date().toISOString(),
tags: ['output'],
preview_url: output.previewUrl,
preview_url: output.url,
user_metadata: metadata
}
}
Expand All @@ -63,7 +62,6 @@ export function mapInputFileToAssetItem(
directory: 'input' | 'output' = 'input'
): AssetItem {
const params = new URLSearchParams({ filename, type: directory })
appendCloudResParam(params, filename)

return {
id: `${directory}-${index}-${filename}`,
Expand Down
2 changes: 1 addition & 1 deletion src/platform/assets/utils/outputAssetUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function mapOutputsToAssetItems({
size: 0,
created_at: createdAtValue,
tags: ['output'],
preview_url: output.previewUrl,
preview_url: output.url,
user_metadata: {
jobId,
nodeId: output.nodeId,
Expand Down
5 changes: 5 additions & 0 deletions src/platform/distribution/cloudPreviewUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ export function appendCloudResParam(
if (filename && getMediaTypeFromFilename(filename) !== 'image') return
params.set('res', '512')
}

export function appendCloudResUrl(url: string): string {
if (!isCloud) return url
return url + '&res=512'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The URLSearchParams piece is a guard for when the asset already has a res set in the URL sent by the server

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Appreciate the catch. I had hoped to make this a smaller PR than reworking the assetsSchema to pass both.

Will start on the nicer fix.

}
3 changes: 0 additions & 3 deletions src/stores/nodeOutputStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import type {
ResultItem,
ResultItemType
} from '@/schemas/apiSchema'
import { appendCloudResParam } from '@/platform/distribution/cloudPreviewUtil'
import { api } from '@/scripts/api'
import { app } from '@/scripts/app'
import { clone } from '@/scripts/utils'
Expand Down Expand Up @@ -120,11 +119,9 @@ export const useNodeOutputStore = defineStore('nodeOutput', () => {

const rand = app.getRandParam()
const previewParam = getPreviewParam(node, outputs)
const isImage = isImageOutputs(node, outputs)

return outputs.images.map((image) => {
const params = new URLSearchParams(image)
if (isImage) appendCloudResParam(params, image.filename)
return api.apiURL(`/view?${params}${previewParam}${rand}`)
})
}
Expand Down
Loading