sanity-io / contentful-to-sanity

Migrate from Contentful to Sanity
MIT License
33 stars 7 forks source link

Images in posts not found #194

Open skoch opened 2 weeks ago

skoch commented 2 weeks ago

Describe the bug

After a successful migration, I added the sanity-plugin-media to view the media that had been migrated. When viewing from the Media tab I can see assets and I can click an asset to view the details. In the "References" tab in the modal, I can see the entry that references the selected asset. When I click into the referenced entry, I am brought to that entry however when looking at the field that contains the asset I see:

image

If I follow the prompt to reset, I see:

image

Which finally choosing "Select" -> "Media" (to access the Media library) I do not see any assets.

To Reproduce

Steps to reproduce the behavior:

  1. Follow the guide to migrate a Contentful project to Sanity
  2. Once running locally, add the sanity-plugin-media to your list of plugins in sanity.config.ts (or js)
  3. View imported assets from the Media tab
  4. Click into an asset
  5. Click to find the referenced entry
  6. View the above "Invalid file value" error
  7. Reset the field, attempt to find the asset in the Media library via "Select" -> "Media"
  8. view an empty Media library

Expected behavior

When migrating, any referenced images should be properly linked to the entry that contains the image.

Screenshots See above

Which versions of Sanity are you using?

@sanity/cli (global)          3.46.1 (up to date)
@sanity/eslint-config-studio   4.0.0 (up to date)
@sanity/vision                3.46.1 (up to date)
sanity                        3.46.1 (up to date)

What operating system are you using?

Mac OS: Sonoma 14.5 (23F79)

Which versions of Node.js / npm are you running?

10.2.0
v21.1.0
skoch commented 2 weeks ago

Seems the type was incorrectly generated as 'file' instead of 'image':

// no good
defineField({name: 'leadImage', type: 'file', title: 'Lead Image', hidden: false}),

// yes!
defineField({name: 'leadImage', type: 'image', title: 'Lead Image', hidden: false}),