Add image uploads with a media library, and event card backgrounds
Uploads (migration 028, server/src/media.js, routes/media.js): editors and up upload JPEG, PNG, GIF, WebP or SVG. Photos are resized to 2400px and saved as WebP by default, or kept as uploaded on request. Files live in UPLOADS_DIR, served by nginx in production and by the API in dev. Admins and up delete, after seeing what still uses the file. Every image field in the editor is now an image widget: preview, the path as text, Upload and Choose from library. A new Media page lists the library. Org lists and event cards now resolve logos through media.ts, so uploaded paths work there. Events get a card_image (migration 029): a photo behind the card under a light veil so the text stays readable. The card's size is unchanged. Setup for production is in docs/media-uploads.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
cd393e4ab2
commit
eaff23839f
26 changed files with 1234 additions and 22 deletions
|
|
@ -18,6 +18,11 @@
|
|||
that column in the server's admin-schema.js or the row will be
|
||||
saved as real input.
|
||||
|
||||
`widget: "image"` is a text box with a preview and upload and
|
||||
library buttons beside it (ImageInput in MediaLibrary.tsx). Its
|
||||
`resolve` option is the media.ts helper for the field's public/
|
||||
directory, so a bare filename previews from the right place.
|
||||
|
||||
Two options change the box itself rather than what goes in it:
|
||||
|
||||
prefix fixed text inside the box, left of the cursor. The
|
||||
|
|
@ -34,6 +39,8 @@
|
|||
|
||||
import { useRef, useState } from "react";
|
||||
|
||||
import { ImageInput } from "./MediaLibrary.tsx";
|
||||
|
||||
const input =
|
||||
"w-full rounded-lg border border-[#4a6b72]/25 bg-white px-3 py-2 text-sm text-[#26454c] " +
|
||||
"outline-none transition-colors focus:border-[#138ba0] focus:ring-2 focus:ring-[#138ba0]/25";
|
||||
|
|
@ -168,6 +175,15 @@ export function Field({ field, value, row, options, error, onChange }: any) {
|
|||
className={locked ? inputLocked : common.className}
|
||||
/>
|
||||
</div>
|
||||
) : widget === "image" ? (
|
||||
<ImageInput
|
||||
id={id}
|
||||
value={value}
|
||||
resolve={field.resolve}
|
||||
locked={locked}
|
||||
className={locked ? inputLocked : common.className}
|
||||
onChange={onChange}
|
||||
/>
|
||||
) : field.prefix && !locked ? (
|
||||
// The span is not a form control, so it can't be typed
|
||||
// into, tabbed to, or selected by dragging through the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue