Skip to content
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

Manually configure asset sources not working #146

Open
shabith opened this issue May 31, 2024 · 0 comments
Open

Manually configure asset sources not working #146

shabith opened this issue May 31, 2024 · 0 comments

Comments

@shabith
Copy link

shabith commented May 31, 2024

Describe the bug

I tried to disable the asset source for a specific schema following the Manually configure asset sources section in README but it is not working.

To Reproduce

Steps to reproduce the behavior:

  1. Create a schema with field type image called movie-image
  2. Try to remove unsplash as asset source for that schema adding following code to the config
import { unsplashImageAsset, unsplashAssetSource } from 'sanity-plugin-asset-source-unsplash'

export default defineConfig({
  // ...
  plugins: [unsplashImageAsset()],
  form: {
    image: {
      assetSources: (previousAssetSources, { schema }) => {
        if (schema.name === 'movie-image') {
          // remove unsplash from movie-image types
          return previousAssetSources.filter((assetSource) => assetSource !== unsplashAssetSource)
        }
        return previousAssetSources
      },
    },
  },
})

Expected behavior

movie-image shouldn't have unsplash as in source dropdown

Which versions of Sanity are you using?

@sanity/cli (global) 3.29.1 (latest: 3.44.0)
@sanity/astro 3.0.0 (latest: 3.1.3)
@sanity/code-input 4.1.4 (up to date)
@sanity/vision 3.41.1 (latest: 3.44.0)
sanity 3.41.1 (latest: 3.44.0)

What operating system are you using?

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

10.5.0
v20.11.0

Additional context

When I console log schema.name it returns undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant