ultra-image-uploader 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +176 -354
- package/dist/components/ImageUploader.d.ts +7 -46
- package/dist/components/ImageUploader.d.ts.map +1 -1
- package/dist/components/ImageUploader.js +83 -93
- package/dist/components/ImageUploader.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -9
- package/dist/index.js.map +1 -1
- package/dist/providers/index.d.ts +23 -17
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +119 -27
- package/dist/providers/index.js.map +1 -1
- package/dist/types/index.d.ts +25 -32
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -1
- package/package.json +5 -6
- package/dist/providers/BaseProvider.d.ts +0 -19
- package/dist/providers/BaseProvider.d.ts.map +0 -1
- package/dist/providers/BaseProvider.js +0 -48
- package/dist/providers/BaseProvider.js.map +0 -1
- package/dist/providers/CloudinaryProvider.d.ts +0 -17
- package/dist/providers/CloudinaryProvider.d.ts.map +0 -1
- package/dist/providers/CloudinaryProvider.js +0 -123
- package/dist/providers/CloudinaryProvider.js.map +0 -1
- package/dist/providers/ImgBBProvider.d.ts +0 -13
- package/dist/providers/ImgBBProvider.d.ts.map +0 -1
- package/dist/providers/ImgBBProvider.js +0 -68
- package/dist/providers/ImgBBProvider.js.map +0 -1
- package/dist/utils/imageUpload.d.ts +0 -11
- package/dist/utils/imageUpload.d.ts.map +0 -1
- package/dist/utils/imageUpload.js +0 -32
- package/dist/utils/imageUpload.js.map +0 -1
- package/dist/utils/upload.d.ts +0 -49
- package/dist/utils/upload.d.ts.map +0 -1
- package/dist/utils/upload.js +0 -62
- package/dist/utils/upload.js.map +0 -1
package/README.md
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
-
A modern,
|
|
5
|
+
A modern, beautiful React image upload component with support for multiple providers.
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/ultra-image-uploader)
|
|
8
|
-
|
|
8
|
+

|
|
9
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
10
|
|
|
10
|
-
**
|
|
11
|
+
**Modern UI** • **Multiple Providers** • **5 Themes** • **Production Ready**
|
|
11
12
|
|
|
12
13
|
</div>
|
|
13
14
|
|
|
@@ -15,32 +16,25 @@ A modern, feature-rich React image upload component with support for multiple ho
|
|
|
15
16
|
|
|
16
17
|
## Features
|
|
17
18
|
|
|
18
|
-
- **
|
|
19
|
-
- **
|
|
20
|
-
- **
|
|
21
|
-
- **
|
|
22
|
-
- **
|
|
23
|
-
- **
|
|
24
|
-
- **
|
|
25
|
-
- **
|
|
26
|
-
- **TypeScript** - Fully typed
|
|
27
|
-
- **
|
|
28
|
-
- **Tree Shakeable** - Optimized bundle size
|
|
19
|
+
- **Beautiful UI** - Modern, clean design with smooth animations
|
|
20
|
+
- **5 Built-in Themes** - Light, Dark, Modern, Ocean, Sunset
|
|
21
|
+
- **Custom Themes** - Create your own color schemes
|
|
22
|
+
- **Multiple Providers** - ImgBB & Cloudinary support
|
|
23
|
+
- **Drag & Drop** - Intuitive file handling
|
|
24
|
+
- **Upload Progress** - Real-time progress tracking
|
|
25
|
+
- **File Validation** - Type and size validation
|
|
26
|
+
- **Auto Upload** - Optional automatic uploading
|
|
27
|
+
- **TypeScript** - Fully typed
|
|
28
|
+
- **Simple API** - Easy to use
|
|
29
29
|
|
|
30
30
|
## Installation
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
33
|
npm install ultra-image-uploader
|
|
34
|
-
# or
|
|
35
|
-
yarn add ultra-image-uploader
|
|
36
|
-
# or
|
|
37
|
-
pnpm add ultra-image-uploader
|
|
38
34
|
```
|
|
39
35
|
|
|
40
36
|
## Quick Start
|
|
41
37
|
|
|
42
|
-
### Basic Usage
|
|
43
|
-
|
|
44
38
|
```tsx
|
|
45
39
|
import { ImageUploader } from "ultra-image-uploader";
|
|
46
40
|
import { useState } from "react";
|
|
@@ -52,447 +46,275 @@ function App() {
|
|
|
52
46
|
<ImageUploader
|
|
53
47
|
images={images}
|
|
54
48
|
setImages={setImages}
|
|
55
|
-
multiple
|
|
49
|
+
multiple
|
|
56
50
|
theme="light"
|
|
57
51
|
/>
|
|
58
52
|
);
|
|
59
53
|
}
|
|
60
54
|
```
|
|
61
55
|
|
|
62
|
-
|
|
56
|
+
## Themes
|
|
57
|
+
|
|
58
|
+
Choose from 5 beautiful themes:
|
|
63
59
|
|
|
64
60
|
```tsx
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
// Light (default)
|
|
62
|
+
<ImageUploader theme="light" images={images} setImages={setImages} />
|
|
67
63
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const [uploadedUrls, setUploadedUrls] = useState<string[]>([]);
|
|
71
|
-
const [loading, setLoading] = useState(false);
|
|
64
|
+
// Dark
|
|
65
|
+
<ImageUploader theme="dark" images={images} setImages={setImages} />
|
|
72
66
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
try {
|
|
76
|
-
const result = await uploadImagesToImageBB(
|
|
77
|
-
images,
|
|
78
|
-
"your-imgbb-api-key-here"
|
|
79
|
-
);
|
|
80
|
-
setUploadedUrls(result.urls);
|
|
81
|
-
console.log("Uploaded URLs:", result.urls);
|
|
82
|
-
} catch (error) {
|
|
83
|
-
console.error("Error uploading images:", error);
|
|
84
|
-
} finally {
|
|
85
|
-
setLoading(false);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
67
|
+
// Modern (pink)
|
|
68
|
+
<ImageUploader theme="modern" images={images} setImages={setImages} />
|
|
88
69
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
multiple={true}
|
|
95
|
-
theme="modern"
|
|
96
|
-
/>
|
|
97
|
-
<button
|
|
98
|
-
onClick={handleUpload}
|
|
99
|
-
disabled={loading || images.length === 0}
|
|
100
|
-
className="bg-blue-500 text-white px-4 py-2 rounded disabled:opacity-50"
|
|
101
|
-
>
|
|
102
|
-
{loading ? "Uploading..." : "Upload to ImgBB"}
|
|
103
|
-
</button>
|
|
104
|
-
|
|
105
|
-
{uploadedUrls.length > 0 && (
|
|
106
|
-
<div>
|
|
107
|
-
<h3>Uploaded Images:</h3>
|
|
108
|
-
{uploadedUrls.map((url) => (
|
|
109
|
-
<img key={url} src={url} alt="Uploaded" />
|
|
110
|
-
))}
|
|
111
|
-
</div>
|
|
112
|
-
)}
|
|
113
|
-
</div>
|
|
114
|
-
);
|
|
115
|
-
}
|
|
70
|
+
// Ocean (cyan)
|
|
71
|
+
<ImageUploader theme="ocean" images={images} setImages={setImages} />
|
|
72
|
+
|
|
73
|
+
// Sunset (orange)
|
|
74
|
+
<ImageUploader theme="sunset" images={images} setImages={setImages} />
|
|
116
75
|
```
|
|
117
76
|
|
|
118
|
-
|
|
77
|
+
## Custom Theme
|
|
119
78
|
|
|
120
79
|
```tsx
|
|
121
|
-
import { ImageUploader,
|
|
122
|
-
|
|
80
|
+
import { ImageUploader, type ThemeConfig } from "ultra-image-uploader";
|
|
81
|
+
|
|
82
|
+
const customTheme: ThemeConfig = {
|
|
83
|
+
primary: '#ff6b6b',
|
|
84
|
+
background: '#fff',
|
|
85
|
+
border: '#ddd',
|
|
86
|
+
text: '#333',
|
|
87
|
+
textSecondary: '#666',
|
|
88
|
+
error: '#e74c3c',
|
|
89
|
+
success: '#2ecc71',
|
|
90
|
+
radius: '8px',
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
<ImageUploader
|
|
94
|
+
images={images}
|
|
95
|
+
setImages={setImages}
|
|
96
|
+
theme={customTheme}
|
|
97
|
+
/>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Upload to ImgBB
|
|
123
101
|
|
|
124
|
-
|
|
102
|
+
```tsx
|
|
103
|
+
import { ImageUploader, uploadImagesToImageBB } from "ultra-image-uploader";
|
|
104
|
+
|
|
105
|
+
function UploadToImgBB() {
|
|
125
106
|
const [images, setImages] = useState<File[]>([]);
|
|
126
|
-
const [loading, setLoading] = useState(false);
|
|
127
107
|
|
|
128
108
|
const handleUpload = async () => {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const results = await uploadImagesToCloudinary(
|
|
132
|
-
images,
|
|
133
|
-
{
|
|
134
|
-
cloudName: "your-cloud-name",
|
|
135
|
-
uploadPreset: "your-upload-preset", // for unsigned uploads
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
onProgress: (progress) => {
|
|
139
|
-
console.log(`Upload: ${progress.percentage}%`);
|
|
140
|
-
},
|
|
141
|
-
transformOptions: {
|
|
142
|
-
width: 800,
|
|
143
|
-
height: 600,
|
|
144
|
-
crop: "limit",
|
|
145
|
-
quality: 80,
|
|
146
|
-
},
|
|
147
|
-
}
|
|
148
|
-
);
|
|
149
|
-
console.log("Uploaded:", results);
|
|
150
|
-
} catch (error) {
|
|
151
|
-
console.error("Error:", error);
|
|
152
|
-
} finally {
|
|
153
|
-
setLoading(false);
|
|
154
|
-
}
|
|
109
|
+
const result = await uploadImagesToImageBB(images, 'YOUR_API_KEY');
|
|
110
|
+
console.log('Uploaded:', result.urls);
|
|
155
111
|
};
|
|
156
112
|
|
|
157
113
|
return (
|
|
158
114
|
<div>
|
|
159
|
-
<ImageUploader
|
|
160
|
-
|
|
161
|
-
setImages={setImages}
|
|
162
|
-
multiple={true}
|
|
163
|
-
theme="dark"
|
|
164
|
-
/>
|
|
165
|
-
<button onClick={handleUpload} disabled={loading}>
|
|
166
|
-
Upload to Cloudinary
|
|
167
|
-
</button>
|
|
115
|
+
<ImageUploader images={images} setImages={setImages} multiple />
|
|
116
|
+
<button onClick={handleUpload}>Upload</button>
|
|
168
117
|
</div>
|
|
169
118
|
);
|
|
170
119
|
}
|
|
171
120
|
```
|
|
172
121
|
|
|
173
|
-
|
|
122
|
+
## Upload to Cloudinary
|
|
174
123
|
|
|
175
124
|
```tsx
|
|
176
|
-
import { ImageUploader } from "ultra-image-uploader";
|
|
177
|
-
import { useState } from "react";
|
|
125
|
+
import { ImageUploader, uploadImagesToCloudinary } from "ultra-image-uploader";
|
|
178
126
|
|
|
179
|
-
function
|
|
127
|
+
function UploadToCloudinary() {
|
|
180
128
|
const [images, setImages] = useState<File[]>([]);
|
|
181
|
-
|
|
129
|
+
|
|
130
|
+
const handleUpload = async () => {
|
|
131
|
+
const results = await uploadImagesToCloudinary(images, {
|
|
132
|
+
cloudName: 'your-cloud-name',
|
|
133
|
+
uploadPreset: 'your-upload-preset',
|
|
134
|
+
});
|
|
135
|
+
console.log('Uploaded:', results.map(r => r.url));
|
|
136
|
+
};
|
|
182
137
|
|
|
183
138
|
return (
|
|
184
|
-
<
|
|
185
|
-
images={images}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
autoUpload={true}
|
|
189
|
-
uploadConfig={{
|
|
190
|
-
provider: "imgbb",
|
|
191
|
-
config: { apiKey: "your-api-key" },
|
|
192
|
-
}}
|
|
193
|
-
onUploadComplete={(urls) => {
|
|
194
|
-
setUploadedUrls(urls);
|
|
195
|
-
console.log("All uploads complete!", urls);
|
|
196
|
-
}}
|
|
197
|
-
onUploadError={(error) => {
|
|
198
|
-
console.error("Upload failed:", error);
|
|
199
|
-
}}
|
|
200
|
-
theme="colorful"
|
|
201
|
-
/>
|
|
139
|
+
<div>
|
|
140
|
+
<ImageUploader images={images} setImages={setImages} multiple theme="dark" />
|
|
141
|
+
<button onClick={handleUpload}>Upload</button>
|
|
142
|
+
</div>
|
|
202
143
|
);
|
|
203
144
|
}
|
|
204
145
|
```
|
|
205
146
|
|
|
206
|
-
##
|
|
207
|
-
|
|
208
|
-
### Built-in Themes
|
|
209
|
-
|
|
210
|
-
The component comes with 5 beautiful themes:
|
|
211
|
-
|
|
212
|
-
- **`light`** - Clean and modern light theme
|
|
213
|
-
- **`dark`** - Sleek dark theme
|
|
214
|
-
- **`modern`** - Purple-themed modern design
|
|
215
|
-
- **`minimal`** - Minimalist black and white
|
|
216
|
-
- **`colorful`** - Warm amber/yellow theme
|
|
147
|
+
## Auto Upload Mode
|
|
217
148
|
|
|
218
149
|
```tsx
|
|
219
|
-
<ImageUploader images={images} setImages={setImages} theme="dark" />
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
### Custom Theme
|
|
223
|
-
|
|
224
|
-
Create your own theme with full customization:
|
|
225
|
-
|
|
226
|
-
```tsx
|
|
227
|
-
import { ImageUploader, type UploaderTheme } from "ultra-image-uploader";
|
|
228
|
-
|
|
229
|
-
const customTheme: UploaderTheme = {
|
|
230
|
-
primary: "#ff6b6b",
|
|
231
|
-
primaryHover: "#ee5a5a",
|
|
232
|
-
background: "#f7f7f7",
|
|
233
|
-
border: "#ddd",
|
|
234
|
-
text: "#333",
|
|
235
|
-
textSecondary: "#666",
|
|
236
|
-
error: "#e74c3c",
|
|
237
|
-
success: "#2ecc71",
|
|
238
|
-
radius: "8px",
|
|
239
|
-
};
|
|
240
|
-
|
|
241
150
|
<ImageUploader
|
|
242
151
|
images={images}
|
|
243
152
|
setImages={setImages}
|
|
244
|
-
|
|
153
|
+
multiple
|
|
154
|
+
autoUpload
|
|
155
|
+
uploadConfig={{
|
|
156
|
+
provider: 'imgbb',
|
|
157
|
+
config: { apiKey: 'your-api-key' },
|
|
158
|
+
}}
|
|
159
|
+
onUploadComplete={(urls) => console.log('Done!', urls)}
|
|
160
|
+
onUploadError={(error) => console.error('Error:', error)}
|
|
245
161
|
/>
|
|
246
162
|
```
|
|
247
163
|
|
|
248
|
-
##
|
|
164
|
+
## Props
|
|
249
165
|
|
|
250
166
|
| Prop | Type | Default | Description |
|
|
251
167
|
|------|------|---------|-------------|
|
|
252
|
-
| `images` | `File[]` | **Required** |
|
|
253
|
-
| `setImages` | `(files: File[]) => void` | **Required** |
|
|
254
|
-
| `
|
|
255
|
-
| `
|
|
256
|
-
| `
|
|
257
|
-
| `
|
|
258
|
-
| `customTheme` | `UploaderTheme` | `undefined` | Custom theme configuration |
|
|
168
|
+
| `images` | `File[]` | **Required** | Selected image files |
|
|
169
|
+
| `setImages` | `(files: File[]) => void` | **Required** | Update images state |
|
|
170
|
+
| `multiple` | `boolean` | `false` | Allow multiple files |
|
|
171
|
+
| `theme` | `'light' \| 'dark' \| 'modern' \| 'ocean' \| 'sunset' \| ThemeConfig` | `'light'` | Theme to use |
|
|
172
|
+
| `mode` | `'add' \| 'update'` | `'add'` | Component mode |
|
|
173
|
+
| `defaultImages` | `string[]` | `[]` | Existing image URLs |
|
|
259
174
|
| `uploadText` | `string` | `'Drop images here...'` | Upload area text |
|
|
260
|
-
| `
|
|
261
|
-
| `
|
|
262
|
-
| `
|
|
263
|
-
| `
|
|
264
|
-
| `
|
|
265
|
-
| `
|
|
266
|
-
| `
|
|
267
|
-
| `
|
|
268
|
-
| `
|
|
269
|
-
| `
|
|
270
|
-
| `
|
|
271
|
-
| `onUploadError` | `(error: Error) => void` | `undefined` | Callback on upload error |
|
|
272
|
-
|
|
273
|
-
## Upload Providers
|
|
274
|
-
|
|
275
|
-
### ImgBB
|
|
276
|
-
|
|
277
|
-
Free image hosting with simple API:
|
|
278
|
-
|
|
279
|
-
```tsx
|
|
280
|
-
import { uploadImagesToImageBB } from "ultra-image-uploader";
|
|
281
|
-
|
|
282
|
-
const result = await uploadImagesToImageBB(
|
|
283
|
-
images,
|
|
284
|
-
"your-imgbb-api-key"
|
|
285
|
-
);
|
|
286
|
-
console.log(result.urls);
|
|
287
|
-
```
|
|
175
|
+
| `maxSize` | `number` | `10485760` | Max file size (bytes) |
|
|
176
|
+
| `allowedTypes` | `string[]` | Image types | Allowed MIME types |
|
|
177
|
+
| `showFileSize` | `boolean` | `true` | Show file size |
|
|
178
|
+
| `dragAndDrop` | `boolean` | `true` | Enable drag-drop |
|
|
179
|
+
| `previewWidth` | `number` | `140` | Preview width (px) |
|
|
180
|
+
| `previewHeight` | `number` | `140` | Preview height (px) |
|
|
181
|
+
| `autoUpload` | `boolean` | `false` | Auto upload files |
|
|
182
|
+
| `uploadConfig` | `{ provider, config }` | `undefined` | Upload config |
|
|
183
|
+
| `onUploadComplete` | `(urls: string[]) => void` | `undefined` | Upload success callback |
|
|
184
|
+
| `onUploadError` | `(error: Error) => void` | `undefined` | Upload error callback |
|
|
185
|
+
| `className` | `string` | `''` | Extra CSS classes |
|
|
288
186
|
|
|
289
|
-
|
|
187
|
+
## Upload Functions
|
|
290
188
|
|
|
291
|
-
###
|
|
189
|
+
### `uploadImage(file, provider, config, options?)`
|
|
292
190
|
|
|
293
|
-
|
|
191
|
+
Upload a single image.
|
|
294
192
|
|
|
295
193
|
```tsx
|
|
296
|
-
import {
|
|
194
|
+
import { uploadImage } from "ultra-image-uploader";
|
|
297
195
|
|
|
298
|
-
const
|
|
299
|
-
|
|
196
|
+
const result = await uploadImage(
|
|
197
|
+
file,
|
|
198
|
+
'imgbb',
|
|
199
|
+
{ apiKey: 'your-key' },
|
|
300
200
|
{
|
|
301
|
-
|
|
302
|
-
uploadPreset: "your-upload-preset", // optional
|
|
303
|
-
},
|
|
304
|
-
{
|
|
305
|
-
onProgress: (progress) => console.log(progress.percentage),
|
|
306
|
-
transformOptions: {
|
|
307
|
-
width: 800,
|
|
308
|
-
height: 600,
|
|
309
|
-
quality: 85,
|
|
310
|
-
crop: "limit",
|
|
311
|
-
},
|
|
201
|
+
onProgress: (p) => console.log(p.percentage + '%'),
|
|
312
202
|
}
|
|
313
203
|
);
|
|
204
|
+
console.log(result.url);
|
|
314
205
|
```
|
|
315
206
|
|
|
316
|
-
|
|
317
|
-
1. Sign up at [cloudinary.com](https://cloudinary.com)
|
|
318
|
-
2. Get your cloud name from dashboard
|
|
319
|
-
3. Create an upload preset (Settings → Upload → Upload presets)
|
|
320
|
-
|
|
321
|
-
## Advanced Usage
|
|
322
|
-
|
|
323
|
-
### Custom Provider
|
|
207
|
+
### `uploadImages(files, provider, config, options?)`
|
|
324
208
|
|
|
325
|
-
|
|
209
|
+
Upload multiple images.
|
|
326
210
|
|
|
327
211
|
```tsx
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
name = 'custom' as const;
|
|
332
|
-
|
|
333
|
-
async upload(file: File, config: ProviderConfig) {
|
|
334
|
-
// Your upload logic here
|
|
335
|
-
return {
|
|
336
|
-
url: "https://...",
|
|
337
|
-
provider: "custom",
|
|
338
|
-
originalFile: file,
|
|
339
|
-
};
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
async uploadMultiple(files: File[], config: ProviderConfig) {
|
|
343
|
-
return Promise.all(files.map(f => this.upload(f, config)));
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// Register and use
|
|
348
|
-
import { providerRegistry } from "ultra-image-uploader";
|
|
349
|
-
providerRegistry.register(new CustomProvider());
|
|
212
|
+
const results = await uploadImages(files, 'cloudinary', {
|
|
213
|
+
cloudName: 'your-cloud',
|
|
214
|
+
});
|
|
350
215
|
```
|
|
351
216
|
|
|
352
|
-
###
|
|
217
|
+
### `uploadImagesToImageBB(images, apiKey)`
|
|
218
|
+
|
|
219
|
+
Upload to ImgBB (shorthand).
|
|
353
220
|
|
|
354
221
|
```tsx
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
validateFileComplete,
|
|
358
|
-
formatFileSize,
|
|
359
|
-
} from "ultra-image-uploader";
|
|
222
|
+
const { urls } = await uploadImagesToImageBB(images, 'api-key');
|
|
223
|
+
```
|
|
360
224
|
|
|
361
|
-
|
|
362
|
-
const validation = validateImageFile(file, {
|
|
363
|
-
maxSize: 5 * 1024 * 1024, // 5MB
|
|
364
|
-
allowedTypes: ["image/jpeg", "image/png"],
|
|
365
|
-
});
|
|
225
|
+
### `uploadImagesToCloudinary(files, config, options?)`
|
|
366
226
|
|
|
367
|
-
|
|
368
|
-
console.error("Errors:", validation.errors);
|
|
369
|
-
}
|
|
227
|
+
Upload to Cloudinary (shorthand).
|
|
370
228
|
|
|
371
|
-
|
|
372
|
-
const
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
maxWidth: 4000,
|
|
376
|
-
minHeight: 600,
|
|
377
|
-
maxHeight: 3000,
|
|
229
|
+
```tsx
|
|
230
|
+
const results = await uploadImagesToCloudinary(images, {
|
|
231
|
+
cloudName: 'your-cloud',
|
|
232
|
+
uploadPreset: 'your-preset',
|
|
378
233
|
});
|
|
379
234
|
```
|
|
380
235
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
Generate transformed URLs for existing Cloudinary images:
|
|
236
|
+
## Get API Keys
|
|
384
237
|
|
|
385
|
-
|
|
386
|
-
|
|
238
|
+
### ImgBB
|
|
239
|
+
1. Go to [imgbb.com/settings/api](https://imgbb.com/settings/api)
|
|
240
|
+
2. Copy your API key
|
|
387
241
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
height: 300,
|
|
393
|
-
crop: "fill",
|
|
394
|
-
quality: 80,
|
|
395
|
-
format: "webp",
|
|
396
|
-
}
|
|
397
|
-
);
|
|
398
|
-
```
|
|
242
|
+
### Cloudinary
|
|
243
|
+
1. Sign up at [cloudinary.com](https://cloudinary.com)
|
|
244
|
+
2. Get your cloud name from dashboard
|
|
245
|
+
3. Create upload preset (Settings → Upload)
|
|
399
246
|
|
|
400
|
-
## TypeScript
|
|
247
|
+
## TypeScript
|
|
401
248
|
|
|
402
|
-
|
|
249
|
+
All types are exported:
|
|
403
250
|
|
|
404
251
|
```tsx
|
|
405
252
|
import type {
|
|
406
253
|
UploadProvider,
|
|
407
254
|
UploadResult,
|
|
408
|
-
|
|
409
|
-
UploadOptions,
|
|
255
|
+
ThemeConfig,
|
|
410
256
|
ImageUploaderProps,
|
|
411
|
-
UploaderTheme,
|
|
412
|
-
ValidationResult,
|
|
413
257
|
FileValidationOptions,
|
|
258
|
+
// ... more
|
|
414
259
|
} from "ultra-image-uploader";
|
|
415
260
|
```
|
|
416
261
|
|
|
417
262
|
## Examples
|
|
418
263
|
|
|
419
|
-
###
|
|
264
|
+
### Profile Picture
|
|
420
265
|
|
|
421
266
|
```tsx
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
<ImageUploader
|
|
430
|
-
images={images}
|
|
431
|
-
setImages={setImages}
|
|
432
|
-
mode="update"
|
|
433
|
-
defaultImages={existingImages}
|
|
434
|
-
multiple={true}
|
|
435
|
-
maxSize={5 * 1024 * 1024} // 5MB
|
|
436
|
-
allowedTypes={["image/jpeg", "image/webp"]}
|
|
437
|
-
theme="modern"
|
|
438
|
-
previewWidth={200}
|
|
439
|
-
previewHeight={200}
|
|
440
|
-
/>
|
|
441
|
-
);
|
|
442
|
-
}
|
|
267
|
+
<ImageUploader
|
|
268
|
+
images={avatar}
|
|
269
|
+
setImages={setAvatar}
|
|
270
|
+
multiple={false}
|
|
271
|
+
maxSize={2 * 1024 * 1024}
|
|
272
|
+
theme="modern"
|
|
273
|
+
/>
|
|
443
274
|
```
|
|
444
275
|
|
|
445
|
-
###
|
|
276
|
+
### Product Gallery
|
|
446
277
|
|
|
447
278
|
```tsx
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
previewWidth={180}
|
|
458
|
-
previewHeight={180}
|
|
459
|
-
theme="minimal"
|
|
460
|
-
/>
|
|
461
|
-
);
|
|
462
|
-
}
|
|
279
|
+
<ImageUploader
|
|
280
|
+
images={products}
|
|
281
|
+
setImages={setProducts}
|
|
282
|
+
multiple
|
|
283
|
+
mode="update"
|
|
284
|
+
defaultImages={existingImages}
|
|
285
|
+
allowedTypes={['image/jpeg', 'image/webp']}
|
|
286
|
+
theme="ocean"
|
|
287
|
+
/>
|
|
463
288
|
```
|
|
464
289
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
If you're upgrading from version 0.0.x, the API is backward compatible:
|
|
290
|
+
### Custom Colors
|
|
468
291
|
|
|
469
292
|
```tsx
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
293
|
+
<ImageUploader
|
|
294
|
+
images={images}
|
|
295
|
+
setImages={setImages}
|
|
296
|
+
theme={{
|
|
297
|
+
primary: '#00d9ff',
|
|
298
|
+
background: '#0a0a0a',
|
|
299
|
+
border: '#333',
|
|
300
|
+
text: '#fff',
|
|
301
|
+
textSecondary: '#999',
|
|
302
|
+
error: '#ff4757',
|
|
303
|
+
success: '#2ed573',
|
|
304
|
+
radius: '16px',
|
|
305
|
+
}}
|
|
306
|
+
/>
|
|
478
307
|
```
|
|
479
308
|
|
|
480
|
-
## Browser Support
|
|
481
|
-
|
|
482
|
-
- Chrome/Edge (latest)
|
|
483
|
-
- Firefox (latest)
|
|
484
|
-
- Safari (latest)
|
|
485
|
-
- Mobile browsers
|
|
486
|
-
|
|
487
309
|
## License
|
|
488
310
|
|
|
489
311
|
MIT © Digontha Das
|
|
490
312
|
|
|
491
|
-
##
|
|
313
|
+
## Links
|
|
492
314
|
|
|
493
|
-
-
|
|
494
|
-
-
|
|
495
|
-
-
|
|
315
|
+
- [GitHub](https://github.com/digontha/ultra-image-uploader)
|
|
316
|
+
- [NPM](https://www.npmjs.com/package/ultra-image-uploader)
|
|
317
|
+
- [Issues](https://github.com/digontha/ultra-image-uploader/issues)
|
|
496
318
|
|
|
497
319
|
---
|
|
498
320
|
|