Netlify-cms: Field level media_folder 馃檲

Created on 4 Feb 2020  路  10Comments  路  Source: netlify/netlify-cms

Is your feature request related to a problem? Please describe.

I think we all knew it would get to this point :) A site of any complexity can easily have an entry with more than one source of images, and the CMS should be able to handle that.

Describe the solution you'd like

  • provide necessary properties/methods to widgets so media_folder/public_folder can be implemented by any widget via config
  • the {{media_folder}} variable in this case would inherit the combined value of the global, collection, and entry (for file collections) media_folder, if any are present.
  • implement media_folder/public_folder in file and image widgets via config
configuration extensionwidgets feature

All 10 comments

Would like to chime in for a subfolder per collection at this point.

Use case:
images/uploads as a site folder (about, hero and whatever content images)
images/products for product images
images/posts for blog posts

@tomrutgers We actually have that already!

https://www.netlifycms.org/docs/beta-features/#folder-collections-media-and-public-folder

Damn I thought it was limited to saving images to the same folder as the markdown post, Gatsby style. Nice!

@erezrokah removed low priority label, just ran into this requirement for a netlify.com page.

implement media_folder/public_folder in file and image widgets

How about we pass them in as field config option?

@barthc right, that's exactly the idea, I'll update the OP to clarify

Did PR #3208 introduced any backward incompatible change with config.xml?
Since netlify-cms@^2.10.18, when accessing a collection entry, getting:
Failed to load entry: t.has is not a function. (In 't.has("media_folder")', 't.has' is undefined)
Thanks!

Hi @gcutrini can you open an issue for it? This might be a bug

Created issue #3251.
Many thanks.

I'm confused. The closing of this story means it has been completed, right? Can I already begin implementing this with config.yml like so...

      - file: "src/pages/cook-offs.md"
        label: "Cook Off's"
        name: "cook-offs"
        fields:
           - label: "Contest Name"
             name: "contestName"
             widget: "string"
             hint: "Avoid using the definite article (i.e. 'The'). This is taken care of by the code when necessary."
           - label: "Image"
             name: "image"
             media_folder: "/contests"
             public_folder: "/img/contests/"
             widget: "image"
             hint: "The logo/image for this year's competition."
Was this page helpful?
0 / 5 - 0 ratings