Skip to content

Incorrect path stored in front matter when media_folder includes slug and title is changed after image upload #5444

@mvolfik

Description

@mvolfik

To Reproduce
Have config like this:

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions