You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i've run into something similar and tried to investigate a bit.
i think there are a couple of issues with {{slug}} in a collection's media_folder and/or public_folder:
folderFormatter passes the current value of the title/identifier_name field to compileStringTemplate, which uses that value to substitute {{slug}}. but when an entry has already been saved (and has a slug assigned), the entry's slug should be used, so the folder path does not change when the title changes.
i think this could be fixed by simply adding this here:
this returns the correct media_folder, except when (i) the collection has a custom slug option, (ii) when there's a name collision (which is solved for the entry slug by generateUniqueSlug).
not really sure how to resolve these. also unclear what the intended behavior of "{{slug}}" should be here: entry.get('slug') will return the slug after it has been transformed by a custom slug collection option, otherwise it just means "a url-safe version of the title field".
for public_folder another issue is that selectMediaFilePublicPath is only called when the medium is selected in the popup dialog. if at that point the identifier_name field is blank, or it is changed afterwards, these changes are not taken into account to generate the image's public_folder path.
To Reproduce
Have config like this:
Expected behavior
An image is uploaded to
/static/assets/bar/filename.png
andimage: /assets/bar/filename.png
is stored in/content/bar.md
Observed behavior
Image is uploaded to correct path
/static/assets/bar/filename.png
, but/content/bar.md
containsimage: /assets/foo/filename.png
Applicable Versions:
netlify-cms-app 2.15.11; netlify-cms-core 2.40.6; netlify-cms 2.10.131
(installed from CDN)The text was updated successfully, but these errors were encountered: