-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Media Library empty when image or file widget has no existing media item selected #3654
Comments
Thinking about this further, the only difference I can see between a new item and an existing item is that the new item does not exist as a file, and so doesn't have a path yet, whereas an existing item represents an exisiting file and therefore does have a path. This would point to the fact that maybe the media library itself is not the problem, but that the root of the path for a new file is being incorrectly generated and prepended to the relative |
Hi @Undistraction this is the intended behaviour with new entries for collections that have relative On a side note the main use case for that feature is to be able to bundle media files in the same folder as the entry when each entry has its own media files and they are not shared between entries. When sharing media files between entries you can prefix the |
@erezrokah this definitely feels like a bug as it makes it impossible to choose an image that already exists in a media directory from a new entry. So every time you create a new entry you would need to upload all the images you need for that entry. In cases where you need an image that already exists, this is problematic. We've had to roll back to using absolute paths as this effectively breaks our CMS for new entries. Users of our CMC need to create new entries and assign various images and downloads found in the media library to fields on those new entries. This is impossible with the current functionality as the media library appears to be empty. In cases where different collections share a centralised media library, new entries need access to that library just as much as existing entries. It sounds like it should be possible use a modified path for new entries so that their This is something I would be happy to look into. |
@erezrokah Sorry. I think you edited your message in the time it took me to reply:
Would this mean that the CMS writes absolute or relative paths to the entries? |
|
@erezrokah Sorry. I think I'm doing a terrible job of explaining my use-case. Let me have another try. Existing setup
Ideal setupThis is what I'd hoped to achieve using the new Beta relative / per collection
It appears that the Ideal setup outlined above is not possible at present because any new entries have an empty media library, preventing existing images or media being added to them. Am I correct in this assumption? Is the ideal setup I outlined above impossible at present? I think this feels like a bug, and that whether for new or existing entries, the library should be populated with all existing media, allowing a new entry to have existing media added to it. If you agree I'd be happy to look into 'fixing' this so that a new media item has access to the media library. Note: The confusion here isn't related to the difference between the |
Thanks for the explanation I think I get it now. I think the ideal setup is possible and actually you don't need to use that feature at all. media_folder: /static/uploads/
public_folder: /uploads
collections:
- name: posts
label: Posts
label_singular: 'Post'
folder: src/content/posts
create: true
public_folder: '../../../static/uploads/'
fields:
- label: Title
name: title
widget: string
- label: 'Cover Image'
name: 'image'
widget: 'image'
required: false
- label: Body
name: body
widget: markdown See the resulting file here: ---
title: test
image: ../../../static/uploads/netlify.png
---
![](../../../static/uploads/netlify.png) Does that cover the use case? Opening the media library for a new entry displays all media files from |
@erezrokah Thanks for putting this together. This does work for me in development, but when I do a production build (with Gatsby), I get an empty media library. |
@erezrokah Update: Is does work, but if I refresh the page the media library is empty, which seems to be an unrelated bug. |
Hi @Undistraction, I'm not sure I understand the new issue - can you provide a reproduction scenario? |
I can write this up as a fresh issue if you like. |
A new issue would be great @Undistraction thanks. Can we close this one? |
@erezrokah Of course. Thanks again for your help. Much much appreciated. |
Describe the bug
When adding a media item to an image or file widget that does not already have a media item assigned when the collection item was loaded, the media library displays the message:
…and the media library modal contains no media at all.
To Reproduce
Expected behavior
It should not make any difference if an image widget has an image assigned or not, it should always show all images within the media library.
Applicable Versions:
CMS configuration
The text was updated successfully, but these errors were encountered: