add 1:1, 3:4

This commit is contained in:
tamaina 2023-04-14 11:37:44 +00:00
parent 8dced67d56
commit 5e5f46f5ae
4 changed files with 22 additions and 4 deletions

View file

@ -475,7 +475,7 @@ existingAccount: "既存のアカウント"
regenerate: "再生成" regenerate: "再生成"
fontSize: "フォントサイズ" fontSize: "フォントサイズ"
mediaListWithOneImageAppearance: "画像が1枚のみのメディアリストの高さ" mediaListWithOneImageAppearance: "画像が1枚のみのメディアリストの高さ"
expandAsImage: "画像に応じて拡張" friendlyRecommended: "おすすめ"
limitTo: "{x}を上限に" limitTo: "{x}を上限に"
noFollowRequests: "フォロー申請はありません" noFollowRequests: "フォロー申請はありません"
openImageInNewTab: "画像を新しいタブで開く" openImageInNewTab: "画像を新しいタブで開く"

View file

@ -54,10 +54,18 @@ function calcAspectRatio() {
return; return;
} }
const ratioMax = (ratio: number) => `${Math.max(ratio, img.properties.width / img.properties.height).toString()} / 1`;
switch (defaultStore.state.mediaListWithOneImageAppearance) { switch (defaultStore.state.mediaListWithOneImageAppearance) {
// //
case '16_9': case '16_9':
gallery.value.style.aspectRatio = Math.max(16 / 9, img.properties.width / img.properties.height).toString() + '/1'; gallery.value.style.aspectRatio = ratioMax(16 / 9);
break;
case '1_1':
gallery.value.style.aspectRatio = ratioMax(1);
break;
case '3_4':
gallery.value.style.aspectRatio = ratioMax(3 / 4);
break; break;
default: default:
gallery.value.style.aspectRatio = ''; gallery.value.style.aspectRatio = '';
@ -205,6 +213,14 @@ const previewable = (file: misskey.entities.DriveFile): boolean => {
max-height: none; max-height: none;
aspect-ratio: 16 / 9; // fallback aspect-ratio: 16 / 9; // fallback
} }
&.n11_1{
max-height: none;
aspect-ratio: 1 / 1; // fallback
}
&.n13_4 {
max-height: none;
aspect-ratio: 3 / 4; // fallback
}
} }
&.n2 { &.n2 {

View file

@ -83,8 +83,10 @@
<MkRadios v-model="mediaListWithOneImageAppearance"> <MkRadios v-model="mediaListWithOneImageAppearance">
<template #label>{{ i18n.ts.mediaListWithOneImageAppearance }}</template> <template #label>{{ i18n.ts.mediaListWithOneImageAppearance }}</template>
<option value="expand">{{ i18n.ts.expandAsImage }}</option> <option value="expand">{{ i18n.ts.friendlyRecommended }}</option>
<option value="16_9">{{ i18n.t('limitTo', { x: '16:9' }) }}</option> <option value="16_9">{{ i18n.t('limitTo', { x: '16:9' }) }}</option>
<option value="1_1">{{ i18n.t('limitTo', { x: '1:1' }) }}</option>
<option value="3_4">{{ i18n.t('limitTo', { x: '3:4' }) }}</option>
</MkRadios> </MkRadios>
</div> </div>
</FormSection> </FormSection>

View file

@ -308,7 +308,7 @@ export const defaultStore = markRaw(new Storage('base', {
}, },
mediaListWithOneImageAppearance: { mediaListWithOneImageAppearance: {
where: 'device', where: 'device',
default: 'expand' as 'expand' | '16_9', default: 'expand' as 'expand' | '16_9' | '1_1' | '3_4',
}, },
})); }));