diff --git a/packages/frontend/src/components/MkImgWithBlurhash.vue b/packages/frontend/src/components/MkImgWithBlurhash.vue index 474ecd361b..caa3895489 100644 --- a/packages/frontend/src/components/MkImgWithBlurhash.vue +++ b/packages/frontend/src/components/MkImgWithBlurhash.vue @@ -1,5 +1,5 @@ @@ -65,16 +65,19 @@ const props = withDefaults(defineProps<{ const viewId = uuid(); const canvas = shallowRef(); +const root = shallowRef(); let loaded = $ref(false); -let canvasWidth = $ref(props.width); -let canvasHeight = $ref(props.height); +let canvasWidth = $ref(64); +let canvasHeight = $ref(64); +let imgWidth = $ref(props.width); +let imgHeight = $ref(props.height); const hide = computed(() => !loaded || props.forceBlurhash); function onLoad() { loaded = true; } -watch([() => props.width, () => props.height], () => { +watch([() => props.width, () => props.height, root], () => { const ratio = props.width / props.height; if (ratio > 1) { canvasWidth = Math.round(64 * ratio); @@ -83,6 +86,10 @@ watch([() => props.width, () => props.height], () => { canvasWidth = 64; canvasHeight = Math.round(64 / ratio); } + + const clientWidth = root.value?.clientWidth ?? 300; + imgWidth = clientWidth; + imgHeight = Math.round(clientWidth / ratio); }, { immediate: true, });