diff --git a/client/src/components/Assistant/cards/journey/JourneyEntriesCard.test.tsx b/client/src/components/Assistant/cards/journey/JourneyEntriesCard.test.tsx
index c143416ad..73054b59b 100644
--- a/client/src/components/Assistant/cards/journey/JourneyEntriesCard.test.tsx
+++ b/client/src/components/Assistant/cards/journey/JourneyEntriesCard.test.tsx
@@ -98,7 +98,7 @@ describe('the journal entries card', () => {
expect(screen.getByText('4 photos')).toBeInTheDocument();
expect(screen.getByText('Opens with a video')).toBeInTheDocument();
expect(screen.getByText('Berlin 2026')).toBeInTheDocument();
- expect(container.querySelector('img')).toHaveAttribute('src', '/api/photos/7/thumbnail');
+ expect(container.querySelector('img')).toHaveAttribute('src', '/api/photos/7/preview');
});
it('FE-AI-JOURNEY-002: an entry without a photo takes the width, and a known mood and weather are named', () => {
@@ -236,7 +236,7 @@ describe('a change row of a journal entry', () => {
expect(screen.getByText('Tue, Oct 21')).toBeInTheDocument();
expect(screen.getByText('Museum Island')).toBeInTheDocument();
expect(screen.queryByText('Not a fact')).toBeNull();
- expect(document.querySelector('img')).toHaveAttribute('src', '/api/photos/7/thumbnail');
+ expect(document.querySelector('img')).toHaveAttribute('src', '/api/photos/7/preview');
first.unmount();
const second = inView(, { onOpen });
diff --git a/client/src/components/Journey/JourneyDetailPageEntryCard.test.tsx b/client/src/components/Journey/JourneyDetailPageEntryCard.test.tsx
index f3751cc73..cdb60b883 100644
--- a/client/src/components/Journey/JourneyDetailPageEntryCard.test.tsx
+++ b/client/src/components/Journey/JourneyDetailPageEntryCard.test.tsx
@@ -59,7 +59,7 @@ describe('EntryCard', () => {
it('FE-JRN-CARD-002: renders the photo hero with the title overlaid', () => {
const { container } = mountCard(buildEntry({ photos: [buildPhoto(100)] }))
- const img = container.querySelector('img[src="/api/photos/100/thumbnail"]')
+ const img = container.querySelector('img[src="/api/photos/100/preview"]')
expect(img).toBeInTheDocument()
expect(screen.getByRole('heading', { name: 'Arrived in Rome' })).toBeInTheDocument()
})
@@ -69,7 +69,7 @@ describe('EntryCard', () => {
const photos = [buildPhoto(100), buildPhoto(101)]
const { container, onPhotoClick } = mountCard(buildEntry({ photos }))
- await user.click(container.querySelector('img[src="/api/photos/101/thumbnail"]') as HTMLElement)
+ await user.click(container.querySelector('img[src="/api/photos/101/preview"]') as HTMLElement)
expect(onPhotoClick).toHaveBeenCalledWith(photos, 1)
})
diff --git a/client/src/components/Journey/JourneyDetailPagePhotoGrid.test.tsx b/client/src/components/Journey/JourneyDetailPagePhotoGrid.test.tsx
index f893ce6c0..fd58fd621 100644
--- a/client/src/components/Journey/JourneyDetailPagePhotoGrid.test.tsx
+++ b/client/src/components/Journey/JourneyDetailPagePhotoGrid.test.tsx
@@ -17,16 +17,16 @@ function buildPhoto(overrides: Partial = {}): JourneyPhoto {
}
describe('PhotoImg', () => {
- it('asks for the thumbnail of a photo', () => {
+ it('asks for the preview of a photo, the size a large tile needs (#2874)', () => {
const { container } = render()
- expect(container.querySelector('img')).toHaveAttribute('src', '/api/photos/515/thumbnail')
+ expect(container.querySelector('img')).toHaveAttribute('src', '/api/photos/515/preview')
})
it('shows the poster of a clip behind the play badge', () => {
const { container } = render()
- expect(container.querySelector('img')).toHaveAttribute('src', '/api/photos/515/thumbnail')
+ expect(container.querySelector('img')).toHaveAttribute('src', '/api/photos/515/preview')
expect(container.querySelector('svg')).not.toBeNull()
})
@@ -43,6 +43,6 @@ describe('PhotoImg', () => {
it('still asks the server for a provider clip, which serves its own poster', () => {
const { container } = render()
- expect(container.querySelector('img')).toHaveAttribute('src', '/api/photos/515/thumbnail')
+ expect(container.querySelector('img')).toHaveAttribute('src', '/api/photos/515/preview')
})
})
diff --git a/client/src/components/Journey/JourneyDetailPagePhotoGrid.tsx b/client/src/components/Journey/JourneyDetailPagePhotoGrid.tsx
index f812b1911..3fec06e29 100644
--- a/client/src/components/Journey/JourneyDetailPagePhotoGrid.tsx
+++ b/client/src/components/Journey/JourneyDetailPagePhotoGrid.tsx
@@ -3,7 +3,8 @@ import type { JourneyPhoto } from '../../store/journeyStore'
import { photoUrl, posterlessVideo } from '../../pages/journeyDetail/JourneyDetailPage.helpers'
export function PhotoImg({ photo, className, style }: { photo: JourneyPhoto; className?: string; style?: React.CSSProperties }) {
- const src = photoUrl(photo, 'thumbnail')
+ // Every tile of the entry grid is a large one (#2874), so it asks for the preview.
+ const src = photoUrl(photo, 'preview')
const isVideo = photo.media_type === 'video'
return (
diff --git a/client/src/components/Journey/JourneyDetailPageProviderPicker.tsx b/client/src/components/Journey/JourneyDetailPageProviderPicker.tsx
index 17316bb16..b3b6141b1 100644
--- a/client/src/components/Journey/JourneyDetailPageProviderPicker.tsx
+++ b/client/src/components/Journey/JourneyDetailPageProviderPicker.tsx
@@ -19,6 +19,7 @@ import {
import type { JourneyEntry, JourneyTrip } from '../../store/journeyStore';
import { DatePicker } from './JourneyDetailPageDatePicker';
import { ScrollTrigger } from './JourneyDetailPageScrollTrigger';
+import { providerAssetUrl } from './providerAssetUrl';
export type ProviderPhotoGroup = { assetIds: string[]; passphrase?: string; mediaTypes?: string[] };
@@ -691,13 +692,13 @@ export function ProviderPicker({
}`}
>
{
const img = e.currentTarget;
- const original = `/api/integrations/memories/${provider}/assets/0/${asset.id}/${userId}/original${selectedAlbumPassphrase ? `?passphrase=${encodeURIComponent(selectedAlbumPassphrase)}` : ''}`;
+ const original = providerAssetUrl(provider, asset.id, userId, 'original', selectedAlbumPassphrase);
if (!img.src.includes('/original')) img.src = original;
}}
/>
diff --git a/client/src/components/Journey/JourneyEntryCover.test.tsx b/client/src/components/Journey/JourneyEntryCover.test.tsx
index 46245f7e9..0a578ab48 100644
--- a/client/src/components/Journey/JourneyEntryCover.test.tsx
+++ b/client/src/components/Journey/JourneyEntryCover.test.tsx
@@ -24,7 +24,7 @@ describe('JourneyEntryCover', () => {
// empty alt and no img role.
const { container } = render( {}} />)
- expect(container.querySelector('img')).toHaveAttribute('src', '/api/photos/7/thumbnail')
+ expect(container.querySelector('img')).toHaveAttribute('src', '/api/photos/7/preview')
expect(screen.getByText('Mercado da Ribeira')).toBeInTheDocument()
expect(screen.getByText('Lisbon, Portugal')).toBeInTheDocument()
})
@@ -35,7 +35,7 @@ describe('JourneyEntryCover', () => {
const { container } = render( {}} />)
// The country's flag is an
of its own, so the photo is queried by source.
- expect(container.querySelector('img[src*="/thumbnail"]')).toBeNull()
+ expect(container.querySelector('img[src*="/api/photos/"]')).toBeNull()
expect(screen.getByText('Mercado da Ribeira')).toBeInTheDocument()
})
@@ -121,7 +121,7 @@ describe('JourneyEntryCover', () => {
const entry = buildEntry({ photos: [{ photo_id: 7, media_type: 'video', provider: 'local', thumbnail_path: null }] })
const { container } = render( {}} />)
- expect(container.querySelector('img[src*="/thumbnail"]')).toBeNull()
+ expect(container.querySelector('img[src*="/api/photos/"]')).toBeNull()
expect(container.querySelector('svg.lucide-play')).toBeInTheDocument()
expect(container.querySelector('svg.lucide-map-pin')).toBeNull()
})
@@ -130,7 +130,7 @@ describe('JourneyEntryCover', () => {
const entry = buildEntry({ photos: [{ photo_id: 7, media_type: 'video', provider: 'local', thumbnail_path: 'journey/poster.jpg' }] })
const { container } = render( {}} />)
- expect(container.querySelector('img')).toHaveAttribute('src', '/api/photos/7/thumbnail')
+ expect(container.querySelector('img')).toHaveAttribute('src', '/api/photos/7/preview')
expect(container.querySelector('svg.lucide-play')).toBeNull()
})
diff --git a/client/src/components/Journey/JourneyEntryCover.tsx b/client/src/components/Journey/JourneyEntryCover.tsx
index 7ccf70bdd..6e7b97162 100644
--- a/client/src/components/Journey/JourneyEntryCover.tsx
+++ b/client/src/components/Journey/JourneyEntryCover.tsx
@@ -91,7 +91,8 @@ export default function JourneyEntryCover({
// A clip without a poster has no picture to fill the card with; its thumbnail
// route 404s and an
pointed at it would draw the broken glyph (#2341).
const posterless = first != null && posterlessVideo(first)
- const src = photoId == null || posterless ? null : photoUrlFor ? photoUrlFor(photoId) : `/api/photos/${photoId}/thumbnail`
+ // The card fills its tile with the photo, too large for the thumbnail (#2874).
+ const src = photoId == null || posterless ? null : photoUrlFor ? photoUrlFor(photoId) : `/api/photos/${photoId}/preview`
const title = cardTitle(entry, t)
const place = cardPlace(entry)
diff --git a/client/src/components/Journey/providerAssetUrl.test.ts b/client/src/components/Journey/providerAssetUrl.test.ts
new file mode 100644
index 000000000..b21dad482
--- /dev/null
+++ b/client/src/components/Journey/providerAssetUrl.test.ts
@@ -0,0 +1,29 @@
+// FE-JRN-ASSETURL-001 to FE-JRN-ASSETURL-003
+import { describe, expect, it } from 'vitest';
+import { providerAssetUrl } from './providerAssetUrl';
+
+describe('providerAssetUrl', () => {
+ it('FE-JRN-ASSETURL-001: a Synology thumbnail names the medium size, so the picker tile is sharp', () => {
+ expect(providerAssetUrl('synologyphotos', '101_ck', 7, 'thumbnail')).toBe(
+ '/api/integrations/memories/synologyphotos/assets/0/101_ck/7/thumbnail?size=m'
+ );
+ });
+
+ it('FE-JRN-ASSETURL-002: an Immich thumbnail and any original name no size', () => {
+ expect(providerAssetUrl('immich', 'a1', 7, 'thumbnail')).toBe(
+ '/api/integrations/memories/immich/assets/0/a1/7/thumbnail'
+ );
+ expect(providerAssetUrl('synologyphotos', '101_ck', 7, 'original')).toBe(
+ '/api/integrations/memories/synologyphotos/assets/0/101_ck/7/original'
+ );
+ });
+
+ it('FE-JRN-ASSETURL-003: a shared album passes its passphrase along, encoded', () => {
+ const src = providerAssetUrl('synologyphotos', '101_ck', 7, 'thumbnail', 'a b&c');
+ expect(src).toContain('passphrase=a%20b%26c');
+ const url = new URL(src, 'http://x');
+ expect(url.searchParams.get('passphrase')).toBe('a b&c');
+ expect(url.searchParams.get('size')).toBe('m');
+ expect(providerAssetUrl('immich', 'a1', 7, 'original', null)).not.toContain('?');
+ });
+});
diff --git a/client/src/components/Journey/providerAssetUrl.ts b/client/src/components/Journey/providerAssetUrl.ts
new file mode 100644
index 000000000..0f8553499
--- /dev/null
+++ b/client/src/components/Journey/providerAssetUrl.ts
@@ -0,0 +1,21 @@
+/**
+ * The address of one asset of a connected photo library, as the picker shows it.
+ *
+ * Synology answers its smallest rendition (240 px) when the request names no
+ * size, and the picker's tiles drew blurry with it (#2874), so a thumbnail asks
+ * for 'm'. Immich has a single thumbnail size on this route and takes none. A
+ * shared album's passphrase goes along, as the server needs it to reach the asset.
+ */
+export function providerAssetUrl(
+ provider: string,
+ assetId: string,
+ userId: number,
+ kind: 'thumbnail' | 'original',
+ passphrase?: string | null
+): string {
+ const query: string[] = [];
+ if (provider === 'synologyphotos' && kind === 'thumbnail') query.push('size=m');
+ if (passphrase) query.push(`passphrase=${encodeURIComponent(passphrase)}`);
+ const search = query.length > 0 ? `?${query.join('&')}` : '';
+ return `/api/integrations/memories/${provider}/assets/0/${assetId}/${userId}/${kind}${search}`;
+}
diff --git a/client/src/mobile/screens/journey/MJourneyFeed.tsx b/client/src/mobile/screens/journey/MJourneyFeed.tsx
index 27573382d..a9b1b5d3d 100644
--- a/client/src/mobile/screens/journey/MJourneyFeed.tsx
+++ b/client/src/mobile/screens/journey/MJourneyFeed.tsx
@@ -170,7 +170,7 @@ function FeedPhoto({ entry }: { entry: JourneyEntry }) {
) : (
{
// img with alt="" is presentational (no 'img' role), so query the DOM directly
const images = document.querySelectorAll('img');
const srcs = Array.from(images).map((img) => img.getAttribute('src'));
- expect(srcs).toContain('/api/photos/100/thumbnail');
+ expect(srcs).toContain('/api/photos/100/preview');
});
});
@@ -413,7 +413,7 @@ describe('JourneyDetailPage', () => {
await renderAndWait();
const imgs = document.querySelectorAll('img');
const photoSrcs = Array.from(imgs).map((img) => img.getAttribute('src'));
- expect(photoSrcs).toContain('/api/photos/100/thumbnail');
+ expect(photoSrcs).toContain('/api/photos/100/preview');
});
});
@@ -452,9 +452,9 @@ describe('JourneyDetailPage', () => {
const imgs = document.querySelectorAll('img');
const photoSrcs = Array.from(imgs).map((img) => img.getAttribute('src'));
- expect(photoSrcs).toContain('/api/photos/100/thumbnail');
- expect(photoSrcs).toContain('/api/photos/101/thumbnail');
- expect(photoSrcs).toContain('/api/photos/102/thumbnail');
+ expect(photoSrcs).toContain('/api/photos/100/preview');
+ expect(photoSrcs).toContain('/api/photos/101/preview');
+ expect(photoSrcs).toContain('/api/photos/102/preview');
});
});
@@ -2576,8 +2576,8 @@ describe('JourneyDetailPage', () => {
// Both photos render in the grid
const imgs = document.querySelectorAll('img');
const srcs = Array.from(imgs).map(img => img.getAttribute('src'));
- expect(srcs).toContain('/api/photos/100/thumbnail');
- expect(srcs).toContain('/api/photos/101/thumbnail');
+ expect(srcs).toContain('/api/photos/100/preview');
+ expect(srcs).toContain('/api/photos/101/preview');
});
});
diff --git a/client/src/pages/JourneyPublicPage.tsx b/client/src/pages/JourneyPublicPage.tsx
index c2c63e998..8f2c601f2 100644
--- a/client/src/pages/JourneyPublicPage.tsx
+++ b/client/src/pages/JourneyPublicPage.tsx
@@ -69,7 +69,11 @@ const WEATHER_CONFIG: Record = {
cold: { icon: Snowflake, label: 'Cold' },
};
-function photoUrl(p: { photo_id: number }, shareToken: string, kind: 'thumbnail' | 'original' = 'original'): string {
+function photoUrl(
+ p: { photo_id: number },
+ shareToken: string,
+ kind: 'thumbnail' | 'preview' | 'original' = 'original'
+): string {
return `/api/public/journey/${shareToken}/photos/${p.photo_id}/${kind}`;
}
@@ -336,7 +340,7 @@ export default function JourneyPublicPage() {
>
{!posterlessVideo(p) && (
) : (
) : (
) : (
setViewingEntry(entry as any)}
- publicPhotoUrl={(photoId) => `/api/public/journey/${token}/photos/${photoId}/thumbnail`}
+ publicPhotoUrl={(photoId) => `/api/public/journey/${token}/photos/${photoId}/preview`}
carouselBottom="calc(env(safe-area-inset-bottom, 16px) + 8px)"
cartoApiKey={cartoApiKey}
layers={mapLayers}
diff --git a/client/src/pages/JourneyPublicPage.wiring.test.tsx b/client/src/pages/JourneyPublicPage.wiring.test.tsx
index e8f987e1e..1efe3a2b4 100644
--- a/client/src/pages/JourneyPublicPage.wiring.test.tsx
+++ b/client/src/pages/JourneyPublicPage.wiring.test.tsx
@@ -170,7 +170,7 @@ describe('JourneyPublicPage wiring', () => {
it('FE-JRN-PUBWIRE-009: a two-photo entry opens the lightbox at the clicked index', () => {
const { hook } = setup({ timelineEntries: [buildEntry({ photos: [photo(1), photo(2)] })] });
- fireEvent.click(document.querySelector('img[src="/api/public/journey/tok-1/photos/20/thumbnail"]')!);
+ fireEvent.click(document.querySelector('img[src="/api/public/journey/tok-1/photos/20/preview"]')!);
expect(hook.setLightbox).toHaveBeenCalledWith(expect.objectContaining({ index: 1 }));
});
@@ -181,7 +181,7 @@ describe('JourneyPublicPage wiring', () => {
expect(screen.getByText('+1')).toBeInTheDocument();
for (const [photoId, index] of [[10, 0], [20, 1], [30, 2]] as const) {
- fireEvent.click(document.querySelector(`img[src="/api/public/journey/tok-1/photos/${photoId}/thumbnail"]`)!.parentElement!);
+ fireEvent.click(document.querySelector(`img[src="/api/public/journey/tok-1/photos/${photoId}/preview"]`)!.parentElement!);
expect(hook.setLightbox).toHaveBeenLastCalledWith(expect.objectContaining({ index }));
}
});
@@ -272,9 +272,10 @@ describe('JourneyPublicPage wiring', () => {
// The cover card draws this URL in an
, so it has to be the poster, not
// the file itself: /original is the clip for a video and a full-size JPEG for
- // a photo (#2341). The own-journey cover already asks for /thumbnail.
+ // a photo (#2341). It fills the card, so it is the preview, as the
+ // own-journey cover's is (#2874).
const publicPhotoUrl = mocks.captured.mobileTimeline.publicPhotoUrl as (id: number) => string;
- expect(publicPhotoUrl(55)).toBe('/api/public/journey/tok-1/photos/55/thumbnail');
+ expect(publicPhotoUrl(55)).toBe('/api/public/journey/tok-1/photos/55/preview');
(mocks.captured.mobileTimeline.onEntryClick as (e: PublicEntry) => void)(buildEntry({ id: 9 }));
expect(hook.setViewingEntry).toHaveBeenCalledWith(expect.objectContaining({ id: 9 }));
diff --git a/client/src/pages/journeyDetail/JourneyDetailPage.helpers.ts b/client/src/pages/journeyDetail/JourneyDetailPage.helpers.ts
index 3e79f9e5f..e6a34bd97 100644
--- a/client/src/pages/journeyDetail/JourneyDetailPage.helpers.ts
+++ b/client/src/pages/journeyDetail/JourneyDetailPage.helpers.ts
@@ -85,7 +85,11 @@ export function formatDate(d: string, locale?: string): { weekday: string; month
};
}
-export function photoUrl(p: { photo_id: number }, size: 'thumbnail' | 'original' = 'thumbnail'): string {
+/**
+ * A journey photo's address. `preview` is the medium rendition for a large tile
+ * (#2874): the thumbnail drew blurry there, the original is far more than it shows.
+ */
+export function photoUrl(p: { photo_id: number }, size: 'thumbnail' | 'preview' | 'original' = 'thumbnail'): string {
return `/api/photos/${p.photo_id}/${size}`;
}
diff --git a/server/src/nest/journey/journey-public.controller.ts b/server/src/nest/journey/journey-public.controller.ts
index 27ca82d28..7e6113638 100644
--- a/server/src/nest/journey/journey-public.controller.ts
+++ b/server/src/nest/journey/journey-public.controller.ts
@@ -18,6 +18,15 @@ import { journeyPublicMapLayersResponseSchema, journeyPublicResponseSchema } fro
import type { Response } from 'express';
import path from 'node:path';
+/**
+ * The size a share link's photo route was asked for. Anything but the two
+ * smaller renditions is the original, as it has always been; `preview` (#2874)
+ * used to fall into that and sent the full image to a large tile.
+ */
+function sharedPhotoKind(kind: string): 'thumbnail' | 'preview' | 'original' {
+ return kind === 'thumbnail' || kind === 'preview' ? kind : 'original';
+}
+
/**
* /api/public/journey — unauthenticated, share-token validated read + photo
* proxy for publicly shared journeys.
@@ -85,7 +94,7 @@ export class JourneyPublicController {
if (!valid) {
throw new HttpException({ error: 'Not found' }, 404);
}
- await this.journey.streamPhoto(res, valid.ownerId, photoId, kind === 'thumbnail' ? 'thumbnail' : 'original');
+ await this.journey.streamPhoto(res, valid.ownerId, photoId, sharedPhotoKind(kind));
}
@Get(':token/photo/:provider/:assetId/:ownerId/:kind')
@@ -101,7 +110,7 @@ export class JourneyPublicController {
throw new HttpException({ error: 'Not found' }, 404);
}
- const wantThumb = kind === 'thumbnail' ? 'thumbnail' : 'original';
+ const wanted = sharedPhotoKind(kind);
if (provider === 'local') {
// Local journey assets are flat filenames. basename() kept for shape;
@@ -134,7 +143,7 @@ export class JourneyPublicController {
res,
provider,
{ userId: effectiveOwnerId, ownerId: effectiveOwnerId, assetId },
- wantThumb,
+ wanted,
);
if (streaming === null) {
res.status(404).json({ error: 'Provider not supported' });
diff --git a/server/src/nest/journey/journey.service.ts b/server/src/nest/journey/journey.service.ts
index fe80ebd2a..db4772186 100644
--- a/server/src/nest/journey/journey.service.ts
+++ b/server/src/nest/journey/journey.service.ts
@@ -184,7 +184,7 @@ export class JourneyService {
return this.share.validateShareTokenForAsset(token, assetId);
}
/** The public share's photo bytes: local files go out without their location. */
- streamPhoto(res: Response, ownerId: number, photoId: number, kind: 'thumbnail' | 'original') {
+ streamPhoto(res: Response, ownerId: number, photoId: number, kind: 'thumbnail' | 'preview' | 'original') {
return this.photoResolver.streamPublicPhoto(res, ownerId, photoId, kind);
}
/**
@@ -201,7 +201,7 @@ export class JourneyService {
res: Response,
provider: string,
ref: { userId: number; ownerId: number; assetId: string },
- kind: 'thumbnail' | 'original',
+ kind: 'thumbnail' | 'preview' | 'original',
): Promise | null {
const backend = this.providers.get(provider);
if (!backend) return null;
diff --git a/server/src/nest/memories/immich.service.ts b/server/src/nest/memories/immich.service.ts
index c1b1b807b..8e0e7fa4d 100644
--- a/server/src/nest/memories/immich.service.ts
+++ b/server/src/nest/memories/immich.service.ts
@@ -544,7 +544,7 @@ export class ImmichService {
response: Response,
userId: number,
assetId: string,
- kind: 'thumbnail' | 'original',
+ kind: 'thumbnail' | 'preview' | 'original',
ownerUserId?: number,
opts?: { mediaType?: string | null; range?: string; publicView?: boolean },
): Promise {
@@ -572,6 +572,12 @@ export class ImmichService {
// Immich generates a poster thumbnail for video too.
url = `${creds.immich_url}/api/assets/${assetId}/thumbnail?size=thumbnail`;
timeout = 10000;
+ } else if (kind === 'preview') {
+ // The medium rendition for a large tile (#2874), a video's poster at that
+ // size too. Re-encoded without the stored metadata, so a share link's
+ // viewer may have it as well.
+ url = `${creds.immich_url}/api/assets/${assetId}/thumbnail?size=preview`;
+ timeout = 30000;
} else if (isVideo) {
// Transcoded, broadly-compatible MP4 with byte-range support; forward the
// viewer's Range so the player can seek. No abort timeout — video is a long
diff --git a/server/src/nest/memories/photo-provider.ts b/server/src/nest/memories/photo-provider.ts
index 5b6beb088..a45e97813 100644
--- a/server/src/nest/memories/photo-provider.ts
+++ b/server/src/nest/memories/photo-provider.ts
@@ -2,8 +2,14 @@ import type { AssetInfo, ServiceResult } from './memories.helpers';
import type { Response } from 'express';
-/** What a caller can ask a provider for. */
-export type PhotoAssetKind = 'thumbnail' | 'original';
+/**
+ * What a caller can ask a provider for. `preview` is the medium rendition a
+ * large tile needs (#2874): the small thumbnail drew blurry there, the original
+ * is far more than a tile shows. A provider sends its own re-encoded
+ * rendition of that size (Immich `preview`, Synology `xl`), never the file as
+ * stored, so it is safe for a share link's viewer too.
+ */
+export type PhotoAssetKind = 'thumbnail' | 'preview' | 'original';
/**
* One asset, and everything a provider needs to reach it.
diff --git a/server/src/nest/memories/photo-resolver.service.ts b/server/src/nest/memories/photo-resolver.service.ts
index d84e68fae..537dec2b2 100644
--- a/server/src/nest/memories/photo-resolver.service.ts
+++ b/server/src/nest/memories/photo-resolver.service.ts
@@ -3,7 +3,7 @@ import { decrypt_api_key } from '../common/crypto/apiKeyCrypto';
import { TrekPhotoRegistrationService } from '../photos/trek-photo-registration.service';
import { StorageService } from '../storage/storage.service';
import { fail, success, type AssetInfo, type ServiceResult } from './memories.helpers';
-import type { PhotoAssetRef } from './photo-provider';
+import type { PhotoAssetKind, PhotoAssetRef } from './photo-provider';
import { PhotoProviderRegistry } from './photo-provider.registry';
import { answerRenditionPending, pendingOrNone, PublicMediaService, RENDITION_PENDING } from './public-media.service';
import { ThumbnailService } from './thumbnail.service';
@@ -96,7 +96,7 @@ export class PhotoResolverService {
res: Response,
userId: number,
photoId: number,
- kind: 'thumbnail' | 'original',
+ kind: PhotoAssetKind,
range?: string,
): Promise {
await this.stream(res, userId, photoId, kind, range, 'owner');
@@ -113,7 +113,7 @@ export class PhotoResolverService {
res: Response,
ownerId: number,
photoId: number,
- kind: 'thumbnail' | 'original',
+ kind: PhotoAssetKind,
): Promise {
await this.stream(res, ownerId, photoId, kind, undefined, 'public');
}
@@ -163,7 +163,7 @@ export class PhotoResolverService {
res: Response,
userId: number,
photoId: number,
- kind: 'thumbnail' | 'original',
+ kind: PhotoAssetKind,
range: string | undefined,
audience: Audience,
): Promise {
@@ -174,7 +174,9 @@ export class PhotoResolverService {
}
if (photo.file_path) {
- if (kind === 'thumbnail') {
+ // A local photo's thumbnail is already the medium size (ThumbnailService,
+ // 800 px), so it is the preview too.
+ if (kind === 'thumbnail' || kind === 'preview') {
const thumbRel = await this.localThumbnail(photo);
if (thumbRel && (await this.sendLocal(res, thumbRel, audience, THUMB_CACHE))) return;
// A poster-less video must NOT fall through to streaming the whole file as a
@@ -220,7 +222,8 @@ export class PhotoResolverService {
);
return;
}
- await provider.streamAsset(res, { ...ref, range, audience }, kind);
+ // Only the original is seekable: a preview is one image and carries no Range.
+ await provider.streamAsset(res, { ...ref, range: kind === 'original' ? range : undefined, audience }, kind);
}
/**
diff --git a/server/src/nest/memories/synology.service.ts b/server/src/nest/memories/synology.service.ts
index 1ceb0c60f..f633a4955 100644
--- a/server/src/nest/memories/synology.service.ts
+++ b/server/src/nest/memories/synology.service.ts
@@ -848,7 +848,7 @@ export class SynologyService {
userId: number,
targetUserId: number,
photoId: string,
- kind: 'thumbnail' | 'original',
+ kind: 'thumbnail' | 'preview' | 'original',
size?: string,
passphrase?: string,
): Promise {
@@ -878,8 +878,9 @@ export class SynologyService {
// Use Thumbnail API for both thumbnail and original — avoids serving raw HEIC files
// (original uses xl size to get a full-resolution JPEG-compatible render).
// Thumbnail default is 'm' (~320px) — 'sm' (240px) looked pixelated on
- // the journey grid on retina screens.
- const resolvedSize = kind === 'original' ? 'xl' : size || 'm';
+ // the journey grid on retina screens. A preview is the large tiles' 'xl'
+ // (#2874), whatever size the caller named.
+ const resolvedSize = kind === 'thumbnail' ? size || 'm' : 'xl';
const params = new URLSearchParams({
api: 'SYNO.Foto.Thumbnail',
method: 'get',
diff --git a/server/src/nest/photos/photos.controller.ts b/server/src/nest/photos/photos.controller.ts
index ed86bee9e..d119bdb54 100644
--- a/server/src/nest/photos/photos.controller.ts
+++ b/server/src/nest/photos/photos.controller.ts
@@ -8,7 +8,7 @@ import { Controller, Get, Headers, HttpException, Param, Res, UseGuards } from '
import type { Response } from 'express';
/**
- * /api/photos/:id/{thumbnail,original,info} — global (not trip-scoped) photo
+ * /api/photos/:id/{thumbnail,preview,original,info} — global (not trip-scoped) photo
* access for the memories/journey features. Streaming endpoints write straight
* to the response via the resolver service.
*
@@ -39,6 +39,18 @@ export class PhotosController {
await this.photos.stream(res, user.id, photoId, 'thumbnail');
}
+ /**
+ * The medium rendition for a large tile (#2874): the provider's preview
+ * (Immich `preview`, Synology `xl`), a local photo's 800 px thumbnail. Same
+ * access check as the other two.
+ */
+ // response-contract-exempt: streams the image bytes through @Res(), there is no JSON body to check.
+ @Get(':id/preview')
+ async preview(@CurrentUser() user: User, @Param('id') id: string, @Res() res: Response): Promise {
+ const photoId = await this.requireAccess(user, id);
+ await this.photos.stream(res, user.id, photoId, 'preview');
+ }
+
@Get(':id/original')
async original(
@CurrentUser() user: User,
diff --git a/server/src/nest/photos/photos.service.ts b/server/src/nest/photos/photos.service.ts
index 7e7b9bb3e..e237a11a0 100644
--- a/server/src/nest/photos/photos.service.ts
+++ b/server/src/nest/photos/photos.service.ts
@@ -20,7 +20,7 @@ export class PhotosService {
return this.access.canAccessTrekPhoto(userId, photoId);
}
- stream(res: Response, userId: number, photoId: number, kind: 'thumbnail' | 'original', range?: string) {
+ stream(res: Response, userId: number, photoId: number, kind: 'thumbnail' | 'preview' | 'original', range?: string) {
return this.resolver.streamPhoto(res, userId, photoId, kind, range);
}
diff --git a/server/tests/e2e/files.e2e.test.ts b/server/tests/e2e/files.e2e.test.ts
index 6f994168c..a87b79c1c 100644
--- a/server/tests/e2e/files.e2e.test.ts
+++ b/server/tests/e2e/files.e2e.test.ts
@@ -225,4 +225,15 @@ describe('Files + photos e2e (real auth guard + temp SQLite)', () => {
expect(res.status).toBe(403);
expect(res.body).toEqual({ error: 'Forbidden' });
});
+
+ it('the preview route answers 401 without a session, 400 for a bad id and 403 without access (#2874)', async () => {
+ expect((await request(server).get('/api/photos/5/preview')).status).toBe(401);
+ const bad = await request(server).get('/api/photos/abc/preview').set('Cookie', sessionCookie(1));
+ expect(bad.status).toBe(400);
+ expect(bad.body).toEqual({ error: 'Invalid photo ID' });
+ helperSvc.canAccessTrekPhoto.mockReturnValue(false);
+ const denied = await request(server).get('/api/photos/5/preview').set('Cookie', sessionCookie(1));
+ expect(denied.status).toBe(403);
+ expect(denied.body).toEqual({ error: 'Forbidden' });
+ });
});
diff --git a/server/tests/integration/memories-synology.test.ts b/server/tests/integration/memories-synology.test.ts
index ab48b841e..86d091743 100644
--- a/server/tests/integration/memories-synology.test.ts
+++ b/server/tests/integration/memories-synology.test.ts
@@ -704,6 +704,27 @@ describe('Synology asset access', () => {
expect(res.status).toBe(200);
});
+ it('SYNO-032c — GET /api/photos/:id/preview asks Synology for its xl rendition (#2874)', async () => {
+ const { user } = await makeUser(orm);
+ await setSynologyCredentials(orm, user.id, 'https://synology.example.com', 'admin', 'pass');
+ const trekPhotoId = await insertRow(orm, TrekPhotos, {
+ provider: 'synologyphotos',
+ asset_id: '101_cachekey',
+ owner: user.id,
+ });
+ vi.mocked(safeFetch).mockClear();
+
+ const res = await request(app).get(`/api/photos/${trekPhotoId}/preview`).set('Cookie', authCookie(user.id));
+
+ expect(res.status).toBe(200);
+ const sizes = vi
+ .mocked(safeFetch)
+ .mock.calls.map((call) => new URL(String(call[0])))
+ .filter((url) => url.searchParams.get('api') === 'SYNO.Foto.Thumbnail')
+ .map((url) => url.searchParams.get('size'));
+ expect(sizes).toEqual(['xl']);
+ });
+
it('SYNO-033 — GET /assets/original streams image data for shared photo', async () => {
const { user: owner } = await makeUser(orm);
const { user: member } = await makeUser(orm);
diff --git a/server/tests/unit/nest/files.controller.test.ts b/server/tests/unit/nest/files.controller.test.ts
index 4e08e1438..f8863757e 100644
--- a/server/tests/unit/nest/files.controller.test.ts
+++ b/server/tests/unit/nest/files.controller.test.ts
@@ -691,6 +691,15 @@ describe('PhotosController', () => {
expect(stream).toHaveBeenCalledWith(res, 1, 5, 'original', undefined);
});
+ it('streams the preview a large tile asks for, behind the same id and access checks (#2874)', async () => {
+ const stream = vi.fn().mockResolvedValue(undefined);
+ await new PhotosController(psvc({ stream })).preview(user2, '5', res);
+ expect(stream).toHaveBeenCalledWith(res, 1, 5, 'preview');
+ await expect(new PhotosController(psvc()).preview(user2, '0x5', res)).rejects.toMatchObject({ status: 400 });
+ const denied = new PhotosController(psvc({ canAccess: vi.fn().mockReturnValue(false) }));
+ await expect(denied.preview(user2, '5', res)).rejects.toMatchObject({ status: 403 });
+ });
+
it('info writes the data, maps a service error', async () => {
const okRes = { status: vi.fn().mockReturnThis(), json: vi.fn() } as unknown as Response;
await new PhotosController(psvc({ info: vi.fn().mockResolvedValue({ data: { id: '5' } }) })).info(
diff --git a/server/tests/unit/nest/immich.service.test.ts b/server/tests/unit/nest/immich.service.test.ts
index 4f299c7cb..dca98356b 100644
--- a/server/tests/unit/nest/immich.service.test.ts
+++ b/server/tests/unit/nest/immich.service.test.ts
@@ -988,6 +988,23 @@ describe('streamImmichAsset', () => {
expect(urls[2]).toContain('/api/assets/v1/video/playback');
});
+ it('IMMICH-041f: a preview asks Immich for its preview rendition, a video its poster at that size (#2874)', async () => {
+ await seedUser(13, 'https://immich.example', 'owner-key');
+ safeFetch.mockResolvedValue(upstream({ contentType: 'image/jpeg', body: 'bytes' }));
+
+ await svc.streamImmichAsset(makeRes() as never, USER, 'a1', 'preview', 13);
+ await svc.streamImmichAsset(makeRes() as never, USER, 'v1', 'preview', 13, {
+ mediaType: 'video',
+ publicView: true,
+ });
+
+ const urls = safeFetch.mock.calls.map((call) => String(call[0]));
+ expect(urls).toEqual([
+ expect.stringContaining('/api/assets/a1/thumbnail?size=preview'),
+ expect.stringContaining('/api/assets/v1/thumbnail?size=preview'),
+ ]);
+ });
+
describe('a public video', () => {
const located = { exifInfo: { latitude: 38.1, longitude: 13.1, fileSizeInByte: 5000 } };
const playback = (total: number) => ({
diff --git a/server/tests/unit/nest/journey.controller.test.ts b/server/tests/unit/nest/journey.controller.test.ts
index db933f7ea..44341fdb4 100644
--- a/server/tests/unit/nest/journey.controller.test.ts
+++ b/server/tests/unit/nest/journey.controller.test.ts
@@ -1191,6 +1191,23 @@ describe('JourneyPublicController', () => {
expect(streamPhoto).toHaveBeenCalledWith({}, 3, 7, 'thumbnail');
});
+ it('both photo proxies hand a preview on as one (#2874), and any other size as the original', async () => {
+ const streamPhoto = vi.fn().mockResolvedValue(undefined);
+ const streamProviderAsset = vi.fn().mockResolvedValue(undefined);
+ const s = svc({
+ validateShareTokenForPhoto: vi.fn().mockReturnValue({ ownerId: 3 }),
+ validateShareTokenForAsset: vi.fn().mockReturnValue({ ownerId: 3 }),
+ streamPhoto,
+ streamProviderAsset,
+ } as Partial);
+ const proxy = new JourneyPublicController(s, storageStub, publicMediaStub);
+ await proxy.photo('tok', 7, 'preview', {} as Response);
+ await proxy.photo('tok', 7, 'huge', {} as Response);
+ await proxy.legacyPhoto('tok', 'immich', 'a1', 'preview', {} as Response);
+ expect(streamPhoto.mock.calls.map((call) => call[3])).toEqual(['preview', 'original']);
+ expect(streamProviderAsset).toHaveBeenCalledWith({}, 'immich', { userId: 3, ownerId: 3, assetId: 'a1' }, 'preview');
+ });
+
it('legacy photo proxy: synology streams, and a failure becomes a 404 json', async () => {
const streamProviderAsset = vi.fn().mockResolvedValue(undefined);
const s = svc({
diff --git a/server/tests/unit/nest/photo-resolver.service.test.ts b/server/tests/unit/nest/photo-resolver.service.test.ts
index 2d44f0097..e98c674c7 100644
--- a/server/tests/unit/nest/photo-resolver.service.test.ts
+++ b/server/tests/unit/nest/photo-resolver.service.test.ts
@@ -443,6 +443,56 @@ describe('streamPhoto — dispatch', () => {
});
});
+describe('streamPhoto — the preview a large tile asks for (#2874)', () => {
+ it('RESOLVE-040: a local photo answers its 800 px thumbnail, for the owner and for a share link alike', async () => {
+ const id = await insertPhoto({
+ provider: 'local',
+ file_path: 'journey/x.jpg',
+ thumbnail_path: 'journey/thumbs/h.jpg',
+ });
+ storage.exists.mockResolvedValue(true);
+ const res = makeRes();
+
+ await svc.streamPhoto(res as never, 1, id, 'preview');
+ await svc.streamPublicPhoto(res as never, 1, id, 'preview');
+
+ expect(storage.sendToResponse.mock.calls.map((call) => call[1])).toEqual(['thumbs/h.jpg', 'thumbs/h.jpg']);
+ expect(publicMedia.renditionFor).not.toHaveBeenCalled();
+ });
+
+ it('RESOLVE-041: a local video without a poster answers 404 rather than the whole clip', async () => {
+ const id = await insertPhoto({ provider: 'local', file_path: 'journey/clip.mp4', media_type: 'video' });
+ storage.exists.mockResolvedValue(true);
+ const res = makeRes();
+
+ await svc.streamPhoto(res as never, 1, id, 'preview');
+
+ expect(res.status).toHaveBeenCalledWith(404);
+ expect(res.json).toHaveBeenCalledWith({ error: 'No poster available' });
+ expect(storage.sendToResponse).not.toHaveBeenCalled();
+ });
+
+ it('RESOLVE-042: a provider photo is asked for its preview past the thumbnail cache, without the Range', async () => {
+ const immichId = await insertPhoto({ provider: 'immich', asset_id: 'a1', owner_id: 5 });
+ const synologyId = await insertPhoto({ provider: 'synologyphotos', asset_id: 's1', owner_id: 9 });
+ const res = makeRes();
+
+ await svc.streamPhoto(res as never, 3, immichId, 'preview', 'bytes=0-99');
+ await svc.streamPhoto(res as never, 4, synologyId, 'preview');
+
+ expect(cache.serveFresh).not.toHaveBeenCalled();
+ expect(immich.streamImmichAsset).toHaveBeenCalledWith(
+ res,
+ 3,
+ 'a1',
+ 'preview',
+ 5,
+ expect.objectContaining({ range: undefined, publicView: false }),
+ );
+ expect(synology.streamSynologyAsset).toHaveBeenCalledWith(res, 4, 9, 's1', 'preview', undefined, undefined);
+ });
+});
+
describe('getPhotoInfo — dispatch', () => {
it('RESOLVE-010: rejects an unknown photo id', async () => {
const result = await svc.getPhotoInfo(1, 999999);