Sanity Media
Alternative media management for Sanity.
⚠ This plugin is currently in alpha. Use at your own risk! ⚠
Background
This plugin provides a dedicated media browser for managing images within Sanity.
Out of the box, it provides a link in the menu where you can view all dataset images from anywhere within your studio.
It can also be used as a custom asset source for image fields.
Features
- Easily access media from the menu
- Grid / table views
- Select and delete multiple assets (shift selection supported in the grid view)
- Display currently selected assets
- Display unused assets
- Display assets referenced in the current document
- Basic filename / date sorting
- View basic file metadata
- Integration with Sanity's snackbar notifications
When sanity-plugin-media
is accessed via a custom asset source, you'll have the option to insert assets as well as view the currently selected image for that field.
Install
In your Sanity project folder:
sanity install media
This will add the Media button to your studio menu. If this is all you're after – that's all you need to do!
Enabling it as a global custom asset source
This plugin exposes part:sanity-plugin-media/asset-source
as a part you can import when defining custom asset sources.
In sanity.json
, add the following snippet the parts
array:
{
"implements": "part:@sanity/form-builder/input/image/asset-sources",
"path": "./parts/assetSources.js"
}
./parts/assetSources.js
:
import MediaAssetSource from 'part:sanity-plugin-media/asset-source'
export default [MediaAssetSource]
Now clicking 'select' on every image field will invoke sanity-plugin-media
.
Read more about Sanity's custom asset sources.
Good to know
- Batch deleting assets invokes multiple API requests - this is because Sanity's transactions are atomic. In other words, deleting 10 selected assets will use 10 API requests.
Roadmap
- Display total image count (Contingent on query engine rewrite)
- More keyboard shortcuts
- Delete confirmation dialog
- Display current document title
- Image uploads
- Multiple selection / insertion
- More detailed metadata views
- Folder management (!)
- Fix typings across the board, consider using
typesafe-actions
- Remember browser options with local storage
- Virtualize displays and improve render performance across large datasets
Contributing
Contributions, issues and feature requests are welcome!