########################################################################
# Media library — reusable uploaded assets referenced via foreignMedia
########################################################################

name: medialib
uploadPath: ../media/medialib
meta:
  label: { de: "Mediathek", en: "Media Library" }
  muiIcon: image_multiple
  group: media
  viewHint:
    media:
      ai:
        targetField: alt
        prompt: Beschreibe das Bild kurz und sachlich fuer einen barrierefreien Alt-Text.
        image:
          maxWidth: 1280
          maxHeight: 1280
          quality: 0.82
      upload:
        autoFill:
          file: file
  preview:
    label: title
    secondary: description
    tertiary: tags
    image: file
    table:
      - file
      - title
      - tags
  subNavigation:
    - name: images
      label: { de: "Bilder", en: "Images" }
      muiIcon: image
      filter:
        file.type_like: ^image/
    - name: documents
      label: { de: "Dokumente", en: "Documents" }
      muiIcon: file_document
      filter:
        file.type_like: ^(?!image/|video/|audio/).+

permissions:
  public:
    methods:
      get: true
  user:
    methods:
      get: true
      post: true
      put: true
      delete: true
  "token:${ADMIN_TOKEN}":
    methods:
      get: true
      post: true
      put: true
      delete: true

imageFilter:
  xs-webp:
    - width: 100
      height: 100
      fit: true
      quality: 60
      outputType: webp
  s-webp:
    - width: 300
      quality: 70
      outputType: webp
  m-webp:
    - width: 600
      quality: 76
      outputType: webp
  l-webp:
    - width: 1200
      quality: 80
      outputType: webp
  xl-webp:
    - width: 2000
      quality: 84
      outputType: webp
  xxl-webp:
    - width: 2800
      quality: 88
      outputType: webp

fields:
  - name: file
    type: file
    validator:
      required: true
      maxFileSize: "50MB"
    meta:
      label: { de: "Datei", en: "File" }
      widget: file
      downscale:
        maxWidth: 2048
        maxHeight: 2048
  - name: title
    type: string
    validator:
      maxLength: 255
    meta:
      label: { de: "Titel", en: "Title" }
  - name: alt
    type: object
    meta:
      label: { de: "Alt-Text", en: "Alt Text" }
    subFields:
      - name: de
        type: string
        validator:
          maxLength: 500
        meta:
          label: Deutsch
      - name: en
        type: string
        validator:
          maxLength: 500
        meta:
          label: English
  - name: description
    type: string
    validator:
      maxLength: 2000
    meta:
      label: { de: "Beschreibung", en: "Description" }
      widget: text
      inputProps:
        multiline: true
        rows: 4
  - name: tags
    type: string[]
    meta:
      label: { de: "Tags", en: "Tags" }
      widget: chipArray
  - name: _testdata
    type: boolean
    meta:
      hide: true
