Skip to content

Commit d410ac0

Browse files
committed
docs: update readme
1 parent c158d37 commit d410ac0

File tree

3 files changed

+33
-47
lines changed

3 files changed

+33
-47
lines changed

README.md

Lines changed: 33 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,29 @@ ImageKit is a complete media storage, optimization, and transformation solution
1212

1313
## Table of Contents
1414

15-
1. [Features](#features)
16-
2. [Prerequisites](#prerequisites)
17-
3. [Installation](#installation)
18-
4. [Configuration](#configuration)
19-
5. [Usage](#usage)
20-
6. [How It Works](#how-it-works)
21-
7. [Asset Data Structure](#asset-data-structure)
22-
8. [Advanced Topics](#advanced-topics)
23-
9. [Contributing](#contributing)
24-
10. [License](#license)
25-
11. [Support](#support)
15+
- [Sanity Plugin for ImageKit.io](#sanity-plugin-for-imagekitio)
16+
- [Table of Contents](#table-of-contents)
17+
- [Features](#features)
18+
- [Prerequisites](#prerequisites)
19+
- [Installation](#installation)
20+
- [Usage](#usage)
21+
- [ImageKit as an asset source](#imagekit-as-an-asset-source)
22+
- [ImageKit as a custom schema type](#imagekit-as-a-custom-schema-type)
23+
- [Asset Data Structure](#asset-data-structure)
24+
- [Advanced Topics](#advanced-topics)
25+
- [Working with Asset URLs](#working-with-asset-urls)
26+
- [Accessing Asset Metadata in Your Frontend](#accessing-asset-metadata-in-your-frontend)
27+
- [Custom Metadata](#custom-metadata)
28+
- [Contributing](#contributing)
29+
- [License](#license)
30+
- [Support](#support)
2631

2732
## Features
2833

2934
- **Media Library Integration**: Browse and manage your ImageKit media library directly in Sanity Studio
3035
- **Asset Source Integration**: Integrates seamlessly with Sanity's image fields
3136
- **Custom Schema Support**: Provides `imagekit.asset` schema type for custom configurations
32-
- **Full-Width Dialog**: Opens ImageKit media library in a full-screen modal dialog
3337
- **Rich Asset Data**: Access complete asset metadata including dimensions, file size, and more.
34-
- **TypeScript Support**: Full type safety with proper interfaces
3538
- **No Configuration Required**: Works out of the box without additional configuration
3639
- **Video Support**: Browse and select both images and video content from ImageKit
3740
- **Asset Preview**: View thumbnails and asset information before selection
@@ -43,7 +46,6 @@ Before you begin, you need:
4346
- A Sanity Studio project (v3 or later)
4447
- Node.js and npm/yarn installed
4548
- An [ImageKit account](https://imagekit.io/registration/) (sign up if you don't have one)
46-
- ImageKit API credentials (Public Key, Private Key, and URL Endpoint)
4749

4850
You can refer to Sanity's [official documentation](https://www.sanity.io/docs) to understand the prerequisites for setting up your Sanity Studio instance.
4951

@@ -62,9 +64,14 @@ yarn add sanity-plugin-imagekit
6264
pnpm install sanity-plugin-imagekit
6365
```
6466

65-
## Configuration
67+
## Usage
68+
69+
This package exports two plugins:
70+
- `imagekitAssetSourcePlugin` - use this if you intend to use ImageKit as an asset source for image fields in your Sanity Studio.
71+
- `imagekitSchemaPlugin` - use this if you intend to define a custom schema type that stores comprehensive asset metadata from ImageKit, allowing you to access detailed information about each asset in your content.
72+
### ImageKit as an asset source
6673

67-
### Step 1: Add the Plugin to Your Sanity Config
74+
To start using this plugin, first import it from the package in your `sanity.config.ts`.
6875

6976
```typescript
7077
// sanity.config.ts
@@ -81,17 +88,9 @@ export default defineConfig({
8188
})
8289
```
8390

84-
The plugin will now be available as an asset source for image fields in your Sanity Studio.
85-
86-
## Usage
87-
88-
### Using ImageKit with Image Fields
89-
90-
ImageKit can be used as an asset source for regular Sanity image fields. When you add an image field to your schema, ImageKit will automatically appear as an option in the asset source dropdown.
91-
92-
#### Option 1: Using Regular Image Fields
91+
Once done, the plugin will now be available as an asset source for image fields in your Sanity Studio. When you add an image field to your schema, ImageKit will automatically appear as an option in the asset source dropdown.
9392

94-
For most use cases, simply use the standard Sanity image field:
93+
For most use cases, you can simply use the standard Sanity image field like:
9594

9695
```typescript
9796
{
@@ -102,15 +101,15 @@ For most use cases, simply use the standard Sanity image field:
102101
}
103102
```
104103

105-
**How to use:**
106-
1. Click on the image field in your document
107-
2. Select "ImageKit" from the asset source dropdown
108-
3. Browse your ImageKit media library
109-
4. Select the image you want to use
104+
<img src="./static/imagekit-asset-source-plugin.png">
110105

111-
#### Option 2: Using Custom ImageKit Asset Type
106+
### ImageKit as a custom schema type
112107

113-
For more control, use the custom `imagekit.asset` schema type:
108+
For more control, you can also use the custom `imagekit.asset` schema type.
109+
110+
<img src="./static/imagekit-schema-type-plugin.png">
111+
112+
To do this, first import the `imagekitSchemaPlugin` from the package.
114113

115114
```typescript
116115
import { imagekitSchemaPlugin } from 'sanity-plugin-imagekit'
@@ -129,19 +128,6 @@ plugins: [imagekitSchemaPlugin()]
129128

130129
This custom type stores comprehensive asset metadata from ImageKit, allowing you to access detailed information about each asset in your content.
131130

132-
## How It Works
133-
134-
The plugin provides a seamless workflow for selecting and managing ImageKit assets:
135-
136-
1. **Access Asset Source**: Click on an image field in your Sanity document
137-
2. **Select ImageKit**: Choose "ImageKit" from the asset source dropdown menu
138-
3. **Browse Media Library**: A full-screen dialog opens displaying your ImageKit media library
139-
4. **Search and Filter**: Use ImageKit's search functionality to find specific assets
140-
5. **Select Asset**: Click on an image or video to select it
141-
6. **Confirm Selection**: The asset is automatically added to your document with all relevant metadata
142-
143-
The plugin maintains a direct connection to your ImageKit account, ensuring you always have access to your latest media assets without the need for manual syncing or imports.
144-
145131
## Asset Data Structure
146132

147133
When you select an image from ImageKit, it's stored with the following comprehensive metadata:
@@ -162,7 +148,7 @@ When you select an image from ImageKit, it's stored with the following comprehen
162148
}
163149
```
164150

165-
NOTE: Since Sanity Studio expects object keys to be matching the regex `/^\$?[a-zA-Z0-9_-]+$/` and ImageKit's Custom Metadata allows characters outside of this set, this plugin sanitizes the keys to replace non-supported characters with underscore i.e. `_`.
151+
**NOTE**: Since Sanity Studio expects object keys to be matching the regex `/^\$?[a-zA-Z0-9_-]+$/` and ImageKit's Custom Metadata allows characters outside of this set, this plugin sanitizes the keys to replace non-supported characters with underscore i.e. `_`.
166152

167153
## Advanced Topics
168154

71.8 KB
Loading
704 KB
Loading

0 commit comments

Comments
 (0)