1.0.22 • Published 9 months ago
@simpleimg/uploader-react v1.0.22
Simple Image Cloud - Uploader Widget for React
This component helps you integrate Simple Image Cloud Uploader Widget with your React App. It allows users to upload images, manage and edit them from their devices, without any backend code.
- Install
- Documentation
- Quick Usage
Single Image -
stringMultiple Image -Array<string>Single Image -ImageObjectMultiple Image -Array<ImageObject> - Image Object
- Feedback
Install
yarn add @simpleimg/uploader-reactor
npm install @simpleimg/uploader-reactDocumentation
You can find the documentation for the Uploader React Component here.
Quick Usage
This component can returns null, string, Array<string>, ImageObject or Array<ImageObject>.
Quick Usage - Single Image - string
- It will returns
stringif value isstringandmax = 1 | undefined. - If no value, an empty string will be returned.
import Uploader from '@simpleimg/uploader-react';
import {
useCallback,
useState
} from 'react';
export default () => {
const [
value,
setValue
] = useState('https://demo.simpleimg.io/image-1.jpg');
/*
sample returned value:
https://demo.simpleimg.io/image-1.jpg
*/
return (
<Uploader apiKey="[YOUR_API_KEY]"
onChange={setValue}
value={value}/>
);
};Quick Usage - Multiple Image - Array<string>
- It will returns
Array<string>if value is like array, or ifmax > 1. - If you set
max=2and provide 3 images, it will returns 2 images. - If no value, an empty array will be returned.
import Uploader from '@simpleimg/uploader-react';
import {
useCallback,
useState
} from 'react';
export default () => {
const [
value,
setValue
] = useState([
'https://demo.simpleimg.io/image-1.jpg',
'https://demo.simpleimg.io/image-2.jpg'
]);
/*
sample returned value:
[
'https://demo.simpleimg.io/image-1.jpg',
'https://demo.simpleimg.io/image-2.jpg'
]
*/
return (
<Uploader apiKey="[YOUR_API_KEY]"
max={2}
onChange={setValue}
value={value}/>
);
};Quick Usage - Single Image - ImageObject
- It will returns
ImageObjectif value is likeobject,ImageObject,nullorundefined, andmax = 1 | undefined. - If no value,
nullwill be returned.
import Uploader from '@simpleimg/uploader-react';
import {
useCallback,
useState
} from 'react';
export default () => {
const [
value,
setValue
] = useState({
url: 'https://demo.simpleimg.io/image-1.jpg'
});
/*
sample returned value:
{
blurHash: string;
colors: [{
count: number;
hex: string;
name: string;
type: string;
}];
contentLength: number;
contentType: string;
createdAt: number;
extension: string;
height: number;
id: string;
putAt: number;
updatedAt: number;
version: number;
width: number;
url: string;
}
*/
return (
<Uploader apiKey="[YOUR_API_KEY]"
onChange={setValue}
value={value}/>
);
};Quick Usage - Multiple Image - Array<ImageObject>
- It will returns
Array<ImageObject>if value is an empty array or with all elements likeobject, or ifmax > 1. - If you set
max=2and provide 3 images, it will returns 2 images.
import Uploader from '@simpleimg/uploader-react';
import {
useCallback,
useState
} from 'react';
export default () => {
const [
value,
setValue
] = useState([{
url: 'https://demo.simpleimg.io/image-1.jpg'
}, {
url: 'https://demo.simpleimg.io/image-2.jpg'
}]);
/*
sample returned value:
[{
blurHash: string;
colors: [{
count: number;
hex: string;
name: string;
type: string;
}];
contentLength: number;
contentType: string;
createdAt: number;
extension: string;
height: number;
id: string;
putAt: number;
updatedAt: number;
version: number;
width: number;
url: string;
}, {
blurHash: string;
colors: [{
count: number;
hex: string;
name: string;
type: string;
}];
contentLength: number;
contentType: string;
createdAt: number;
extension: string;
height: number;
id: string;
putAt: number;
updatedAt: number;
version: number;
width: number;
url: string;
}]
*/
return (
<Uploader apiKey="[YOUR_API_KEY]"
max={2}
onChange={setValue}
value={value}/>
);
};Image Object
interface ImageObject {
// The image's blurHash: see more at https://blurha.sh/
blurHash: string;
// The image's dominant colors
colors: Array<{
count: number;
hex: string;
name: string;
type: string;
}>;
// The image's content length
contentLength: number;
// The image's content type
contentType: string;
// The image's first creation date
createdAt: number;
// The image's extension
extension: string;
// The image's height
height: number;
// The image's id
id: string;
// The image's last creation date (it will changes if you upload same image)
putAt: number;
// The image's last update date
updatedAt: number;
// The image's version
version: number;
// The image's width
width: number;
// The image's url
url: string;
}Feedback
We want to hear your issue reports and feature requests at support@simpleimagecloud.com
1.0.19
9 months ago
1.0.18
9 months ago
1.0.17
9 months ago
1.0.16
9 months ago
1.0.22
9 months ago
1.0.21
9 months ago
1.0.20
9 months ago
1.0.15
1 year ago
1.0.13
1 year ago
1.0.12
1 year ago
1.0.11
2 years ago
1.0.2
3 years ago
1.0.9
3 years ago
1.0.8
3 years ago
1.0.7
3 years ago
1.0.6
3 years ago
1.0.5
3 years ago
1.0.4
3 years ago
1.0.3
3 years ago
1.0.10
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago