Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Delete removed images using Folder Collections Media  #5097

@seanburlington

Description

@seanburlington

possibly related to Delete path folder when delete entry #3615

Describe the bug
When using Folder Collections Media a folder is created for the post, images are loaded from and saved to this folder

They are not accessible to the media assets UI

When removing an image from the page it is not deleted from git

To Reproduce
In config.yml use a collection storing images in a folder for the post

  1. path creates a folder
  2. media_folder is relative to this folder
  3. a list of images is used

Create a post with at least one image

publish

Edit that post and delete the image

Expected behavior

I would expect the image to be deleted from the post front matter and from git

What happens is that the image is deleted from frontmatter but not from git

You can replace the image in frontmatter with a new image but not remove the old one

You can't remove it via the media assets tool either as it isn't in the folder this looks at.

While the image isn't in frontmatter it may still be used by the site generator (eg Hugo still sees this as a valid Page Resource)

Applicable Versions:

netlify-cms-app 2.14.28
netlify-cms-core 2.38.6
netlify-cms 2.10.98

Gitlab

Ubuntu

Chromium Version 89.0.4389.82 (Official Build) snap (64-bit)

CMS configuration

backend:
  name: git-gateway
  branch: master # Branch to update (optional; defaults to master)
collections:
  - name: "gallery" # Used in routes, e.g., /admin/collections/blog
    label: "Gallery" # Used in the UI
    folder: "content/gallery" # The path to the folder where the documents are stored
    slug: "{{year}}-{{slug}}" # Filename template, e.g., YYYY-MM-DD-title.md
    path: '{{slug}}/index'
    media_folder: ''
    public_folder: '/content/gallery/{{year}}-{{slug}}/'
    create: true # Allow users to create new documents in this collection
    fields: # The fields for each document, usually in front matter
      - {label: "Title", name: "title", widget: "string"}
      - {label: "Publish Date", name: "date", widget: "datetime"}
      - {label: "Description", name: "description", widget: "string"}
      - label: "Keywords"
        name: "tags"
        widget: "list"
      - label: "Images"
        name: "images"
        widget: "list"
        summary: '{{fields.image}}'
        field: {label: Image, name: image, widget: image}
      - {label: "Body", name: "body", widget: "markdown"}

Additional context

Using media folders per page works very well mainly - but there is a need to be able to manage these images.

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