You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-47Lines changed: 33 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,26 +12,29 @@ ImageKit is a complete media storage, optimization, and transformation solution
12
12
13
13
## Table of Contents
14
14
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)
26
31
27
32
## Features
28
33
29
34
-**Media Library Integration**: Browse and manage your ImageKit media library directly in Sanity Studio
30
35
-**Asset Source Integration**: Integrates seamlessly with Sanity's image fields
31
36
-**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
33
37
-**Rich Asset Data**: Access complete asset metadata including dimensions, file size, and more.
34
-
-**TypeScript Support**: Full type safety with proper interfaces
35
38
-**No Configuration Required**: Works out of the box without additional configuration
36
39
-**Video Support**: Browse and select both images and video content from ImageKit
37
40
-**Asset Preview**: View thumbnails and asset information before selection
@@ -43,7 +46,6 @@ Before you begin, you need:
43
46
- A Sanity Studio project (v3 or later)
44
47
- Node.js and npm/yarn installed
45
48
- 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)
47
49
48
50
You can refer to Sanity's [official documentation](https://www.sanity.io/docs) to understand the prerequisites for setting up your Sanity Studio instance.
-`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
66
73
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`.
68
75
69
76
```typescript
70
77
// sanity.config.ts
@@ -81,17 +88,9 @@ export default defineConfig({
81
88
})
82
89
```
83
90
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.
93
92
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:
95
94
96
95
```typescript
97
96
{
@@ -102,15 +101,15 @@ For most use cases, simply use the standard Sanity image field:
102
101
}
103
102
```
104
103
105
-
**How to use:**
106
-
1. Click on the image field in your document
107
-
2. Select "ImageKit" from the asset source dropdown
This custom type stores comprehensive asset metadata from ImageKit, allowing you to access detailed information about each asset in your content.
131
130
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
-
145
131
## Asset Data Structure
146
132
147
133
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
162
148
}
163
149
```
164
150
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. `_`.
0 commit comments