Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete removed images using Folder Collections Media #5097

Closed
seanburlington opened this issue Mar 11, 2021 · 2 comments
Closed

Delete removed images using Folder Collections Media #5097

seanburlington opened this issue Mar 11, 2021 · 2 comments

Comments

@seanburlington
Copy link

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.

@seanburlington seanburlington added the type: bug code to address defects in shipped code label Mar 11, 2021
@erezrokah
Copy link
Contributor

Hi @seanburlington, to get the image deleted you'll need to click choose different image and delete it from within the media library dialog (clicking remove image is not enough).

Does that work for you?

@seanburlington
Copy link
Author

ahh - yes and I can manage the page images from there

Thank you

I think I was thrown by clicking "remove image" which removed the image from the "page" but not the folder

I will write up a post on how to use netlify-cms with Hugo page bundles as it hasn't been 100% clear to me

If there is a way to contribute docs let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants