0

这是 NetlifyCMS 的 config.yml 的相关部分,我想在其中使用 Uploadcare 的图像小部件为图库选择多个图像:

media_library:
  name: uploadcare
  config:
    publickey: mypublicapikey
media_folder: "/src/images/"
public_folder: "/src/images/"
collections:
  - label: "Projects" 
    name: "projects" 
    folder: "src/data/projects" 
    media_folder: 'images' 
    media_library:
      name: uploadcare
      config:
        publickey: mypublicapikey
    fields: # The fields for each document, usually in front matter
      - {label: "Image", name: "image", widget: "image", allow_multiple: false}
      - label: "Gallery Images"
        name: "images"
        widget: "image"
        options:
          media_library:
            config:
              multiple: true
              previewStep: false

这导致我只能选择一个图像的小部件。我试过 shift/ctrl/ctrl+shift 单击其他条目,但它不起作用。文档说允许多个图像是默认设置,但这不是我遇到的行为。

4

1 回答 1

0

要让 Uploadcare 正常工作,您可能需要为 netlify-cms 安装 uploadcare 插件:

npm i netlify-cms-media-library-uploadcare --save

我按照此处发布的解决方案进行了分解:

  1. 在 src 中创建一个 cms 文件夹
  2. 将 cms.js 文件添加到 src/cms 文件夹
  3. 添加此代码:
import CMS from 'netlify-cms-app'
import uploadcare from 'netlify-cms-media-library-uploadcare';

CMS.registerMediaLibrary(uploadcare);

然后按照Uploadcare的文档进行操作。

于 2020-01-22T04:23:36.093 回答