re-add alt-text

This commit is contained in:
Min Idzelis
2025-04-23 21:41:09 +00:00
parent 6cb7fffe91
commit 0795f8a761
8 changed files with 39 additions and 33 deletions

View File

@@ -1,5 +1,4 @@
import type { TimelineAsset } from '$lib/stores/assets-store.svelte';
import { AssetTypeEnum, type AssetResponseDto } from '@immich/sdk';
import { t } from 'svelte-i18n';
import { derived } from 'svelte/store';
import { fromLocalDateTime } from './timeline-util';
@@ -44,24 +43,18 @@ export const getAltTextForTimelineAsset = (_: TimelineAsset) => {
};
export const getAltText = derived(t, ($t) => {
return (asset: AssetResponseDto | null | undefined) => {
if (!asset) {
return '';
}
if (asset.exifInfo?.description) {
return asset.exifInfo.description;
}
return (asset: TimelineAsset) => {
const date = fromLocalDateTime(asset.localDateTime).toLocaleString({ dateStyle: 'long' });
const hasPlace = !!asset.exifInfo?.city && !!asset.exifInfo?.country;
const names = asset.people?.filter((p) => p.name).map((p) => p.name) ?? [];
const { city, country, people: names } = asset.text;
const hasPlace = city && country;
const peopleCount = names.length;
const isVideo = asset.type === AssetTypeEnum.Video;
const isVideo = asset.isVideo;
const values = {
date,
city: asset.exifInfo?.city,
country: asset.exifInfo?.country,
city,
country,
person1: names[0],
person2: names[1],
person3: names[2],

View File

@@ -114,6 +114,14 @@ export const toTimelineAsset = (unknownAsset: AssetResponseDto | TimelineAsset):
const assetResponse = unknownAsset as AssetResponseDto;
const { width, height } = getAssetRatio(assetResponse);
const ratio = width / height;
const city = assetResponse.exifInfo?.city;
const country = assetResponse.exifInfo?.country;
const people = assetResponse.people?.map((person) => person.name) || [];
const text = {
city: city || null,
country: country || null,
people,
};
return {
id: assetResponse.id,
ownerId: assetResponse.ownerId,
@@ -129,6 +137,7 @@ export const toTimelineAsset = (unknownAsset: AssetResponseDto | TimelineAsset):
duration: assetResponse.duration || null,
projectionType: assetResponse.exifInfo?.projectionType || null,
livePhotoVideoId: assetResponse.livePhotoVideoId || null,
text,
};
};
export const isTimelineAsset = (arg: AssetResponseDto | TimelineAsset): arg is TimelineAsset =>

View File

@@ -1,4 +1,5 @@
import { browser } from '$app/environment';
function getBoolean(string: string | null, fallback: boolean) {
if (string === null) {
return fallback;
@@ -11,13 +12,11 @@ function getNumber(string: string | null, fallback: number) {
}
return Number.parseInt(string);
}
const storage = browser
? localStorage
: {
getItem: () => null,
};
export const TUNABLES = {
LAYOUT: {
WASM: getBoolean(storage.getItem('LAYOUT.WASM'), false),