1.0.22 • Published 6 months ago

@simpleimg/uploader-react v1.0.22

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

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

yarn add @simpleimg/uploader-react

or

npm install @simpleimg/uploader-react

Documentation

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 string if value is string and max = 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 if max > 1.
  • If you set max=2 and 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 ImageObject if value is like object, ImageObject, null or undefined, and max = 1 | undefined.
  • If no value, null will 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 like object, or if max > 1.
  • If you set max=2 and 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

6 months ago

1.0.18

6 months ago

1.0.17

6 months ago

1.0.16

6 months ago

1.0.22

6 months ago

1.0.21

6 months ago

1.0.20

6 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

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.10

2 years ago

1.0.1

2 years ago

1.0.0

3 years ago