Incorrect path stored in front matter when media_folder includes slug and title is changed after image upload
- Dominant language
- JavaScript
- Stars
- 19.4k
- Forks
- 3.1k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 9
Description
**To Reproduce**
Have config like this:
```yml
backend:
name: "git-gateway"
local_backend: true
media_folder: "/static/assets"
public_folder: "/assets"
slug:
clean_accents: true
encoding: "ascii"
collections:
- name: "content"
label: "Content"
folder: "content"
media_folder: "{{media_folder}}/{{slug}}"
public_folder: "{{public_folder}}/{{slug}}"
create: true
fields:
- label: "Title"
name: "title"
widget: "string"
- label: "Image"
name: "image"
widget: "image"
allow_multiple: false
```
1. Create a new item
2. Set title to 'foo' (or don't set it at all)
3. Upload some image and choose it in the second widget
4. Change the title to 'bar'
5. Publish
**Expected behavior**
An image is uploaded to `/static/assets/bar/filename.png` and `image: /assets/bar/filename.png` is stored in `/content/bar.md`
**Observed behavior**
Image is uploaded to correct path `/static/assets/bar/filename.png`, but `/content/bar.md` contains `image: /assets/foo/filename.png`
**Applicable Versions:**
- Netlify CMS version: `netlify-cms-app 2.15.11; netlify-cms-core 2.40.6; netlify-cms 2.10.131` (installed from CDN)
- Git provider: Happens with both local dev server and Netlify Git gateway
Contributor guide
Assessment
This issue has not been assessed yet.