61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
import path from "path";
|
|
import { fileURLToPath } from "url";
|
|
import type { CollectionConfig } from "payload";
|
|
import { isAdmin } from "@/access";
|
|
|
|
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
|
export const Media: CollectionConfig = {
|
|
slug: "media",
|
|
labels: {
|
|
singular: "Bild",
|
|
plural: "Bilder",
|
|
},
|
|
admin: {
|
|
group: "Inhalte",
|
|
useAsTitle: "alt",
|
|
description: "Bilder für die Website. Alt-Text und Bildbeschreibung sind optional. Bis zu 100 Dateien pro Upload.",
|
|
},
|
|
access: {
|
|
// Images are public so the website can display them without a login.
|
|
read: () => true,
|
|
create: isAdmin,
|
|
update: isAdmin,
|
|
delete: isAdmin,
|
|
},
|
|
upload: {
|
|
staticDir: path.resolve(dirname, "..", "media"),
|
|
bulkUpload: true,
|
|
// SVG deliberately excluded: it can carry inline <script>/event-handler
|
|
// payloads that execute if the raw file is ever opened directly (not via
|
|
// <img>) - not currently needed by any part of the site.
|
|
mimeTypes: ["image/jpeg", "image/png", "image/webp"],
|
|
imageSizes: [
|
|
{ name: "thumbnail", width: 400, position: "centre" },
|
|
{ name: "card", width: 800, position: "centre" },
|
|
{ name: "hero", width: 1600, position: "centre" },
|
|
],
|
|
adminThumbnail: "thumbnail",
|
|
formatOptions: { format: "webp", options: { quality: 82 } },
|
|
},
|
|
fields: [
|
|
{
|
|
name: "alt",
|
|
type: "text",
|
|
label: "Alt-Text",
|
|
required: false,
|
|
admin: {
|
|
description: "Optional. Kann später für Barrierefreiheit und SEO ergänzt werden.",
|
|
},
|
|
},
|
|
{
|
|
name: "caption",
|
|
type: "textarea",
|
|
label: "Bildbeschreibung",
|
|
admin: {
|
|
description: "Optionale, längere Beschreibung (z. B. für eine Bildunterschrift).",
|
|
},
|
|
},
|
|
],
|
|
};
|