From 7dce46e651b5279c61e7d937d8b7e063f4d9b81f Mon Sep 17 00:00:00 2001 From: Ayaka Rizumu <464388324@qq.com> Date: Wed, 14 Dec 2022 02:30:40 +0800 Subject: [PATCH] fix: don't stretch smaller preview card images (#413) --- components/status/StatusPreviewCard.vue | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/components/status/StatusPreviewCard.vue b/components/status/StatusPreviewCard.vue index 93afe5c2..c91f99da 100644 --- a/components/status/StatusPreviewCard.vue +++ b/components/status/StatusPreviewCard.vue @@ -8,8 +8,17 @@ const props = defineProps<{ /** When it is root card in the list, not appear as a child card */ root?: boolean }>() + +// mastodon's default max og image width +const ogImageWidth = 400 + const alt = $computed(() => `${props.card.title} - ${props.card.title}`) -const isSquare = $computed(() => props.smallPictureOnly || props.card.width === props.card.height) +const isSquare = $computed(() => ( + props.smallPictureOnly + || props.card.width === props.card.height + || Number(props.card.width || 0) < ogImageWidth + || Number(props.card.height || 0) < ogImageWidth / 2 +)) const providerName = $computed(() => props.card.providerName ? props.card.providerName : new URL(props.card.url).hostname) // TODO: handle card.type: 'photo' | 'video' | 'rich';