Cloudinary using a string value instead of an array when selecting a single image
- Dominant language
- JavaScript
- Stars
- 19.4k
- Forks
- 3.1k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 9
Description
**Describe the bug**
This issue is the same as the one described here #2573
> When selecting 2 images via Cloudinary media_library, the image strings are saved in markdown as an array. When selecting 1 image, it is saved in markdown as a string.
**To Reproduce**
1. Use the following configuration
```
backend:
name: git-gateway
branch: master
local_backend: true
media_library:
name: cloudinary
config:
cloud_name: #REPLACE-THIS
api_key: #REPLACE-THIS
media_folder: static/img
public_folder: /img
collections:
- name: "items"
editor:
preview: false
label: "items"
folder: "content/items"
create: true
slug: "{{slug}}"
fields:
- { label: "Name", name: "title", widget: "string" }
- label: "multiple images"
name: "images"
widget: "image"
media_library:
config:
multiple: true
```
2. Create a new item with two images
3. Create a new item with a single image
4. You should have 2 new files
```
---
title: One
images:
- https://res.cloudinary.com/chromjs/image/upload/v1623377465/laptop1_xzo5ac.jpg
- https://res.cloudinary.com/chromjs/image/upload/v1623194500/sample.jpg
---
```
```
---
title: Two
images: https://res.cloudinary.com/chromjs/image/upload/v1623377465/laptop1_xzo5ac.jpg
---
```
**Expected behavior**
Item "Two" should be an array of a single item
I created a repo with the minimal configuration:
https://github.com/chromjs/cloudinary_array_issue
**Applicable Versions:**
```
"gatsby": "^3.13.0",
"gatsby-plugin-netlify-cms": "^5.13.0",
"netlify-cms-app": "^2.15.44",
"netlify-cms-media-library-cloudinary": "^1.3.10",
"react": "^17.0.1",
"react-dom": "^17.0.1"
```
**CMS configuration**
```
backend:
name: git-gateway
branch: master
local_backend: true
media_library:
name: cloudinary
config:
cloud_name: #REPLACE-THIS
api_key: #REPLACE-THIS
media_folder: static/img
public_folder: /img
collections:
- name: "items"
editor:
preview: false
label: "items"
folder: "content/items"
create: true
slug: "{{slug}}"
fields:
- { label: "Name", name: "title", widget: "string" }
- label: "multiple images"
name: "images"
widget: "image"
media_library:
config:
multiple: true
```
Contributor guide
Assessment
This issue has not been assessed yet.