Mediathek: zentrale Bildverwaltung mit Verwendungsnachweis und Bildauswahl

- Tabellen media und media_usages, Modelle Media/MediaUsage
- App\Media\MediaLibrary (store/register/replace/delete/rebuild) und
  Registry App\Media\MediaUsages (Quellen: Seiten, Neuigkeiten inkl.
  künftiger content-Spalte, Termine, Startseiten-Kacheln), ImagePaths-Extraktor
- Alle Uploads landen in der Mediathek (Seiten-Editor direkt, übrige über
  Beobachter beim Speichern); Daten-Migration und media:rebuild übernehmen
  bestehende Bilder
- Recht media.manage, Zugang media.use für alle Redaktionsbereiche
- /redaktion/mediathek (Suche, Filter, Upload mit Fortschritt, Details,
  Eingebunden in, Ersetzen, Löschen mit Warnung, Mehrfachauswahl),
  Abschnitt in der Redaktion und Menüpunkt im Admin-Bereich
- MediaPicker (Hochladen/Mediathek) im Pagebuilder: Bildfelder und
  Galerie (Mehrfachauswahl), editor.pickMedia im provide-API
- Bild-URLs mit ?v=Änderungszeit, null bei fehlender Datei; Modelle löschen
  geteilte Bilder nicht mehr selbst

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-26 20:05:50 +00:00
parent 3b72b5327e
commit 694ccf6ae0
46 changed files with 3101 additions and 89 deletions

View file

@ -0,0 +1,51 @@
import { reactive } from 'vue';
/**
* Bildauswahl als Promise – für Editoren (Pagebuilder, Neuigkeiten …):
*
* const picker = useMediaPicker({ upload: (file, onProgress) => …, contextPaths: () => [...] });
* const items = await picker.pick({ multiple: true }); // null bei Abbruch
* // items: [{ id, path, url, alt, caption, width, height }]
*
* Im Template einmal <MediaPickerHost :picker="picker" /> einbinden.
*
* @param {{ upload?: Function, contextPaths?: () => string[], contextLabel?: string }} defaults
*/
export function useMediaPicker(defaults = {}) {
const state = reactive({
open: false,
multiple: false,
title: '',
contextPaths: [],
contextLabel: defaults.contextLabel ?? 'Hier verwendet',
upload: defaults.upload ?? null,
resolve: null,
});
/**
* @param {{ multiple?: boolean, title?: string, contextPaths?: string[] }} options
* @returns {Promise<Array<{id: number, path: string, url: string, alt: string, caption: string, width: number, height: number}> | null>}
*/
function pick(options = {}) {
state.resolve?.(null);
return new Promise((resolve) => {
Object.assign(state, {
multiple: !!options.multiple,
title: options.title ?? '',
contextPaths: options.contextPaths ?? defaults.contextPaths?.() ?? [],
resolve,
open: true,
});
});
}
function finish(items) {
const resolve = state.resolve;
state.resolve = null;
state.open = false;
resolve?.(items);
}
return { state, pick, finish };
}