Files
ComfyUI_frontend/src/components/common/ComfyImage.vue
Christian Byrne 0babdb4fe3 [backport cloud/1.42] fix: high-res image preview overflowing screen and hiding close button (#10129) (#10894)
Backport of #10129 to cloud/1.42. Clean cherry-pick.

Co-authored-by: Jin Yi <jin12cc@gmail.com>
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Alexander Brown <drjkl@comfy.org>
Co-authored-by: GitHub Action <action@github.com>
2026-04-06 14:57:24 -07:00

56 lines
1.2 KiB
Vue

<!-- A image with placeholder fallback on error -->
<template>
<span v-if="!error" :class="cn('contents', contain && 'relative')">
<img
v-if="contain"
:src="src"
:data-test="src"
class="absolute inset-0 object-cover"
:style="{ 'background-image': `url(${src})` }"
:alt="alt"
/>
<img
:src="src"
:class="
cn(
'z-1 size-full object-cover object-center',
contain && 'absolute object-contain backdrop-blur-[10px]',
classProp
)
"
:alt="alt"
/>
</span>
<div
v-if="error"
class="m-8 flex size-full flex-col items-center justify-center"
>
<i class="pi pi-image mb-2 text-5xl" />
<span>{{ $t('g.imageFailedToLoad') }}</span>
</div>
</template>
<script setup lang="ts">
import { useImage } from '@vueuse/core'
import { computed } from 'vue'
import { cn } from '@/utils/tailwindUtil'
const {
src,
class: classProp,
contain = false,
alt = 'Image content'
} = defineProps<{
src: string
class?:
| string
| Record<string, boolean>
| (string | Record<string, boolean>)[]
contain?: boolean
alt?: string
}>()
const { error } = useImage(computed(() => ({ src, alt })))
</script>