2026-02-14 10:30:27 +01:00
|
|
|
/**
|
|
|
|
|
* Custom next/image loader for Immich proxy.
|
|
|
|
|
*
|
|
|
|
|
* Referenced by next.config.ts via images.loaderFile.
|
2026-09-29 22:50:30 +02:00
|
|
|
* Generates URLs that point to our /api/image proxy route.
|
2026-02-14 10:30:27 +01:00
|
|
|
*
|
|
|
|
|
* The src passed to next/image should already be a full proxy URL
|
2026-09-29 22:50:30 +02:00
|
|
|
* (e.g. /api/image/<token>?size=preview). This loader appends the width —
|
|
|
|
|
* collapsed to the width of the Immich tier it resolves to, so every srcset
|
|
|
|
|
* candidate of one tier is the same URL (see canonicalImageUrl).
|
2026-02-14 10:30:27 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
'use client';
|
|
|
|
|
|
2026-09-29 22:50:30 +02:00
|
|
|
import { canonicalImageUrl } from './imageSize';
|
|
|
|
|
|
2026-02-14 10:30:27 +01:00
|
|
|
interface ImageLoaderParams {
|
2026-02-14 11:47:26 +01:00
|
|
|
src: string;
|
|
|
|
|
width: number;
|
|
|
|
|
quality?: number;
|
2026-02-14 10:30:27 +01:00
|
|
|
}
|
|
|
|
|
|
2026-09-29 22:50:30 +02:00
|
|
|
export default function immichLoader({ src, width }: ImageLoaderParams): string {
|
|
|
|
|
return canonicalImageUrl(src, width);
|
2026-02-14 10:30:27 +01:00
|
|
|
}
|