NetlifyCMS无法使用Uploadcare“图像”小部件选择多个图像

时间:2020-01-21 04:56:28

标签: netlify-cms uploadcare

这是我config.yml中有关NetlifyCMS的相关部分,在这里我想使用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点击其他条目,但没有用。文档说默认允许多张图片,但这不是我遇到的问题。

1 个答案:

答案 0 :(得分:0)

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

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

我遵循发布于here的解决方案进行了分解:

  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);

然后按照docs进行Uploadcare。