Closed wittenbrock closed 3 years ago
@erezrokah - Thanks for fixing this so quickly. As of 2.14.29
, I can confirm that image and file widgets with the media_folder
property are successfully overriding the global media folder.
Cheers
Hi guys, before creating a new issue I would like to ask here if the following is expected
If I add an image widget after a file widget with the media_folder overwritten, and I want the images to be saved in the folder defined in the root, I would imagine that the configuration would be something like this
media_folder: src/netlify-cms-uploads # Declare the global media folder
public_folder: /files
collections:
- name: blog
label: Blog
label_singular:
folder: src/pages/blog
identifier_field: title
extension: md
create: true
slug: '{{slug}}'
preview_path: 'blog/{{slug}}'
fields:
- label: Download
name: download
widget: file
media_folder: /src/pdfs/blog # Override the global media_folder and save pdfs in a different directory
- label: Thumbnail
name: thumbnail
widget: image # Without adding a media_folder, since I want to use the one from the root (src/netlify-cms-uploads)
but in this way, when accessing the CMS, when opening the image selector, it shows empty with the message "not assets" even when the folder has images.
so the way I found it to work, is by specifying the path in the image widget, is this expected or a bug?
media_folder: src/netlify-cms-uploads # Declare the global media folder
public_folder: /files
collections:
- name: blog
label: Blog
label_singular:
folder: src/pages/blog
identifier_field: title
extension: md
create: true
slug: '{{slug}}'
preview_path: 'blog/{{slug}}'
fields:
- label: Download
name: download
widget: file
media_folder: /src/pdfs/blog # Override the global media_folder and save pdfs in a different directory
- label: Thumbnail
name: thumbnail
widget: image
media_folder: src/netlify-cms-uploads
The Bug
In
netlify-cms-app@2.14.27
, whenmedia_folder
is set on an image or file widget it does not override the globalmedia_folder
.This issue could be related to or a duplicate of issue #4529.
Expected Behavior
In Netlify CMS's documentation and PR# 3208, it explains that the
media_folder
can be declared globally, for a collection, or for a widget. As of March 10th, 2021, the ability to setmedia_folder
for a collection or widget is a beta feature.CMS Configuration
Here's a portion of my
admin/config.yml
:The above syntax does not override the global
media_folder
.Instead of saving the images at
src/images/blog
and the pdf files atsrc/pdfs/blog
, Netlify CMS saves the images and files in the globalmedia_folder
=src/netlify-cms-uploads
. This means that setting themedia_folder
at the widget level is not supported.While Netlify CMS incorrectly saves the images and files in the global
media_folder
, it does write the image and file paths correctly in the blog post markdown files that it generates:Environment and npm packages