Image uploaded to wrong location on first submission
- Dominant language
- JavaScript
- Stars
- 19.4k
- Forks
- 3.1k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 9
Description
**Describe the bug**
When I submit a new item in a collection (containing text and image), the image is not uploaded to the path specified in `media_folder` for this field. The output in the json is correct, the `media_folder` path is shown correctly. It seems to upload the image to the path specified in the root `media_folder` on the first submission.
Re-uploading the image a second time fixes the issue. The image gets uploaded correctly to the path specified in the `media_folder` at the image field level.
**To Reproduce**
I've created a repo where you can see this issue happening: https://github.com/ameego/netlifycms-issue.
1. Checkout the repo
2. `npm install`
2. `npm run develop`
3. Access the cms
4. Add a new artist by filling artist name, slug and upload an image
5. Upon submission, image will be uploaded to `static/assets`. The json file created under `collection/artists` will show the correct path for the image.
6. Try to re-upload the image. The image will be uploaded to the correct location.
**Expected behavior**
I would expect the image to be uploaded to the location specified in `media_folder` at the image level.
**Applicable Versions:**
netlify-cms-app 2.12.19
netlify-cms-core 2.30.3
Git provider: github
OS: macOS Catalina
Node: v10.15.3
**CMS configuration**
```
backend:
name: github
repo: ameego/netlifycms-issue
branch: master
site_domain: cms.netlify.com
media_folder: static/assets
public_folder: /assets
collections:
- label: Artistes
name: artists
summary: "{{artistName}}"
label_singular: artiste
folder: "collections/artists"
create: true
slug: "{{artistName}}"
extension: json
editor:
preview: false
fields:
- label: "Nom de l'artiste"
name: artistName
- name: slug
label: "Slug"
pattern:
[
"^[a-z0-9]+(?:-[a-z0-9]+)*$",
"A slug can have no spaces or special characters",
]
- label: Bannière
name: banner
widget: image
required: false
media_folder: "/static/assets/banner/{{fields.slug}}"`
```
Thank you for your help.
Contributor guide
Assessment
This issue has not been assessed yet.