Resolve every record image from the uploads folder

A bare image filename, whatever it belongs to (organization and event
logos, people photos, team and award logos, backgrounds, hero photos,
block images), now resolves to /uploads/<file>, in media.ts and for
link previews in pageMeta.js. The per-kind public/ folders were
guesses that don't exist. Only the site's own chosen assets, the NGU
logos in the nav, footer and admin, stay bundled from
src/assets/logos.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-27 23:29:54 -05:00
parent 9eeb13c5ec
commit dad3803ccc
6 changed files with 55 additions and 56 deletions

View file

@ -27,8 +27,8 @@
/admin noindex
Image paths resolve like src/lib/media.ts does: a bare filename
lives in that record kind's public/ directory, anything starting
with / or a scheme is used as it is. Keep DIRS in step with it.
is in the uploads directory, anything starting with / or a scheme
is used as it is.
An SVG isn't used as a preview image (the big sites won't show
one), so it falls back to the site default.
═══════════════════════════════════════════════════════════════ */
@ -45,16 +45,9 @@ export const SITE_CONFIG = path.resolve(process.env.SITE_CONFIG ?? path.join(her
const DESCRIPTION_CHARS = 160;
/* Where a bare filename lives, per kind. Mirrors src/lib/media.ts. */
const DIRS = {
person: "/people",
eventLogo: "/uploads",
eventBackground: "/event-backgrounds",
organization: "/org-logos",
team: "/team-logos",
award: "/award-logos",
blog: "/blog",
};
/* Where a bare filename lives: record images are uploads, whatever
kind they are. Mirrors src/lib/media.ts. */
const UPLOADS = "/uploads";
/* ── site.json, reread when it changes ─────────────────────── */
@ -94,9 +87,9 @@ const first = (...values) => values.find((v) => v != null && String(v).trim() !=
function imageUrl(site, file, kind) {
if (!file || /\.svg(\?|#|$)/i.test(file)) return null;
// A bare filename is in that kind's directory, or at the site's
// root for the site's own default (kind null).
const pathOrUrl = /^(https?:|\/)/.test(file) ? file : kind ? `${DIRS[kind]}/${file}` : `/${file}`;
// A record's bare filename is an upload; the site's own default
// image (kind null) is a path from the site's root.
const pathOrUrl = /^(https?:|\/)/.test(file) ? file : kind ? `${UPLOADS}/${file}` : `/${file}`;
return /^https?:/.test(pathOrUrl) ? pathOrUrl : `${origin(site)}${pathOrUrl}`;
}