/* ═══════════════════════════════════════════════════════════════ MEDIA PATHS Every image field in the API is a filename or a path, and where a bare filename lives is decided here, in one file. One rule: record images are uploads. A value from the media library is already '/uploads/'; a bare filename is a file copied into the uploads directory by hand (fall-retreat-logo.svg was), so it resolves to /uploads/ too. That covers logos, photos, backgrounds, hero slides, block images: everything an editor picks. The site's own chosen assets (the NGU logos in the nav, footer and admin) are the exception: they're bundled from src/assets/logos and imported where they're used, not resolved here. A value that already looks like a path or a URL is returned untouched, so a hand-written entry can point anywhere. server/src/pageMeta.js resolves images for link previews by the same rule; keep the two in step. ═══════════════════════════════════════════════════════════════ */ const ABSOLUTE = /^(https?:|\/|data:)/ const UPLOADS = '/uploads' /* Any record image or media field (photos, logos, backgrounds, hero slides and video files, block and card images, blog covers), and the timeline's and featured cards' `{ file, kind }` logos by their file. One rule for all of them; if a kind ever needs its own directory, that's the time to add a parameter. */ export function mediaUrl(file?: string | null): string | null { if (!file) return null if (ABSOLUTE.test(file)) return file return `${UPLOADS}/${file}` } /* Initials for a photo that is missing or fails to load. Same two-word rule PeopleTiles uses. */ export function initials(name = ''): string { return name .trim() .split(/\s+/) .slice(0, 2) .map((word) => word[0] || '') .join('') .toUpperCase() }