Skip to content

Images uploaded in a collection sub media_folder aren't deleted when they should #6642

@oreilles

Description

@oreilles

When a media_folder and public_folder are used for a specific collection, the uploaded images for that collection aren't deleted when a collection item is deleted.

To Reproduce

  1. Use the following config:
collections:
  - name: posts
    label: Posts
    label_singular: 'Post'
    folder: content/posts
    path: '{{slug}}/index'
    media_folder: ''
    public_folder: ''
    fields:
      - label: Title
        name: title
        widget: string
      - label: 'Cover Image'
        name: 'image'
        widget: 'image'
  1. Create a post with an uploaded image
  2. Delete the post
  3. The index.md file is deleted, but the containing folder, including the uploaded image, are preserved.

Expected behavior
The image and folder structure of the post should be deleted too, since the image can't be referenced by other posts or any other collection items (See #5910). For the same reason they can't be referenced everywhere else, they also cannot be deleted from anywhere else in netlify-cms.

Applicable Versions:

  • Netlify CMS version: 2.15.72
  • Git provider: Gitlab
  • OS: macOS
  • Browser version: Firefox 108.0.1

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