I am creating a new collection
in NetlifyCMS called media
and would like to know if it is possible to use the image filename as the identifier_field
and slug
.
So if I had an image titled ocean.png
, adding a new entry in the media collection would result in content/media/ocean.md
At the moment, when I use identifier_field: media
, the filename for the markdown file comes out as content/media/media-ocean-jpg.md
. This is not bad, but ideally would like to get it down to just the filename.
Example
# MEDIA =======================
- name: "media" # Used in routes, e.g., /admin/collections/blog
label: "Media" # Used in the UI
label_singular: 'Media'
description: "TKTK"
folder: "content/media" # path to the folder where files are stored
create: true # Allow users to create new documents in this collection
identifier_field: media # sets the field that is used to create the slug
slug: "{{slug}}"
fields: # The fields for each document, usually in frontmatter
- label: "Media"
name: "media"
widget: "image"
hint: "TKTK"
prompt: true
media_library:
config:
multiple: true
- label: "Name"
name: "name"
widget: "string"
hint: "TKTK"
required: false
- label: "Image Alt"
name: "alt"
widget: "string"
hint: "TKTK"
- label: "Image Caption"
name: "caption"
widget: "string"
hint: "TKTK"
required: false
- label: "Image Credit"
name: "credit"
widget: "string"
hint: "TKTK"
required: false
- label: "Date"
name: "date"
widget: "datetime"
dateFormat: "YYYY-MM-DD" # e.g. 24.12.2021
timeFormat: "HH:mm" # e.g. 21:07
format: "YYYY-MM-DD HH:mm:00 -0500"
What I have tried thus far
- adding
prompt: true
to see if it would allow the user to edit the upload filename, referenced here How to auto rename the file name of uploaded file or image? · Issue #857 · netlify/netlify-cms · GitHub. - adding
{{filename}}
to the slug and/or to the path