sveltia / sveltia-cms

Alternative to Netlify/Decap CMS. Fast, lightweight, Git-based headless CMS. Modern UX, first-class i18n support, open source & free. Made with Svelte.
MIT License
863 stars 43 forks source link

Pre-existing images not displayed in gallery #57

Closed dsgibbons closed 1 year ago

dsgibbons commented 1 year ago

First of all, thank you for making this. I much prefer using this to Decap CMS.

I have a gallery configured like so in config.yml:

collections: # A list of collections the CMS should be able to edit
  - name: 'myGallery' 
    label: 'My Gallery'
    folder: 'src/routes/myGallery'
    create: true
    fields:
      - { label: 'Title', name: 'title', widget: 'string' }
      - { label: 'Publish Date', name: 'date', widget: 'datetime' }
      - { label: 'Body', name: 'body', widget: 'markdown' }
      - { label: 'Thumbnail', name: 'thumbnail', widget: 'image' }
      - label: 'Gallery'
        name: 'galleryImages'
        widget: 'list'
        summary: '{{fields.image}}'
        field: { label: Image, name: image, widget: image }

When I go to the UI, pre-existing images don't appear in the gallery, even though they are in the Markdown metadata under galleryImages. If I re-add the images via Svelta CMS, the images appear in the UI. However, the resulting Markdown is unchanged, and if I reload the post in the UI, the images disappear again.

kyoshino commented 1 year ago

Hey, thanks for checking out Sveltia CMS! My quick local test couldn’t reproduce the issue. Do you use the GitHub backend or the local repository? #35 may be related, but not sure. 🤔

dsgibbons commented 1 year ago

I'm using the GitHub backend. I'm not sure if this is the same issue as #35. The gallery images show up fine in Decap CMS.

kyoshino commented 1 year ago

Hmm, I’m puzzled. What are your media_folder and typical image paths?

Sveltia CMS only displays images stored under the global and collection-specific media_folders (field-specific folders are not supported yet, but it’s probably not the case here). For example, If media_folder is static/uploads, static/images/favicon.png won’t show up in the gallery, which is intentional.

dsgibbons commented 1 year ago

Ok I know the problem now.

In the markdown preamble, DecapCMS produces:

---
title: ...
date: ...
thumbnail: ...
galleryImages:
  - /uploads/img1.jpg
  - /uploads/img2.jpg
---

where SveltiaCMS produces:

---
title: ...
date: ...
thumbnail: ...
galleryImages:
  - image: /uploads/img1.jpg
  - image: /uploads/img2.jpg
---

I had previously created the markdown using DecapCMS, so the gallery images weren't viewable in Sveltia. I think I prefer the DecapCMS format - can Sveltia be changed to match?

kyoshino commented 1 year ago

Thanks for looking into this! So it’s a compatibility issue in Sveltia. I’ll fix it for sure.

kyoshino commented 1 year ago

The fix is in 🎉