Website 1.7.0: move and zoom photos in their frame; delete unused photos

- A section's photo (hero, welcome, invitation, image-text) shows in the
  shape of its frame for the current template and layout, with a Move and
  zoom dialog: drag or arrow keys to choose what stays in view, zoom to
  300%. Saved with the section as data.framing ({ x, y, zoom } by media
  id), a draft until published. The site draws it with object-position
  and scale() around that point; Bold split/collage frames now clip, and
  a zoomed photo stays inside Heritage's mat. Framing for photos a section
  no longer shows is dropped on save.
- Media library: each photo says where it's used; one used nowhere can be
  deleted with its files (DELETE /admin/media/:id, 409 IN_USE otherwise,
  audited as media_deleted).

Checked: Website backend tests (135) and typecheck, frontend typecheck,
lint and production build, and an e2e test of both flows in Chromium.
Lighthouse not run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-27 23:34:10 +02:00
co-authored by Claude Opus 5.5
parent 25100bd749
commit a9215ac4e4
22 changed files with 494 additions and 50 deletions
@@ -1,10 +1,10 @@
"use client";
import { useState } from "react";
import { api } from "@/admin/api";
import { api, canEdit } from "@/admin/api";
import { gb, StorageMeter, Uploader, type MediaItem, type Storage } from "@/admin/media";
import { Btn, inputClass, Loading, Notice, Panel, Title, useAction, useAdmin, when } from "@/admin/ui";
import { Image as ImageIcon } from "lucide-react";
import { Image as ImageIcon, Trash2 } from "lucide-react";
/** The media library (§10): uploads, what each photo shows (alt text), and storage used. */
export default function Media() {
@@ -15,6 +15,7 @@ export default function Media() {
const { busy, message, run } = useAction();
if (!data) return <Loading error={error} />;
const manager = ["owner", "admin"].includes(me.data?.user.role ?? "");
const editor = canEdit(me.data?.user.role ?? "");
const s = data.storage;
return (
<>
@@ -35,6 +36,15 @@ export default function Media() {
)}
{!m.alt && <p className="text-xs font-medium text-amber-800">Add what it shows, for people who can&apos;t see it.</p>}
<p className="text-xs text-gray-500">{m.width && m.height ? `${m.width} × ${m.height}` : ""} · {gb(m.bytes)}</p>
{m.usedIn?.length ? (
<p className="text-xs text-gray-600">Used on: {m.usedIn.join(", ")}</p>
) : editor && (
<Btn kind="danger" busy={busy} onClick={() => {
if (window.confirm(`Delete this photo${m.alt ? ` (“${m.alt}”)` : ""}? It isn't used anywhere. This can't be undone.`)) {
void run(async () => { await api(`/media/${m.id}`, { method: "DELETE" }); await reload(); }, "Deleted.");
}
}}><Trash2 className="h-4 w-4" aria-hidden />Delete</Btn>
)}
</li>
))}
</ul>