1.1.7 • Published 7 months ago

react-image-manager v1.1.7

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Upload

Manage Image Library

How it works

This lib allows yo do two things :

  • Crop images and upload them to your server (using react-image-crop library). The server will receive all info to resize the image (gist to help for server below)
  • See your images in galleries, and select the one you want

Make it work

  1. At the root of your React tree, wrap your app with ImageManagerContainer component.

    import { ImageManagerContainer } from "react-image-manager";
    <ImageManagerContainer>
       <App />
    </ImageManagerContainer>
  2. Pass the right props to ImageManagerContainer to make it work. Constraint the crop ratio, pass the array of images that will be displayed, allow or disallow multi selection, choose min width of image upload...

  3. To make the component appear, use the hook useImageManager

    import { useImageManager } from "react-image-manager";
    const { isDisplayedImageManager, setIsDisplayedImageManager } = useImageManager();
    setIsDisplayedImageManager(true); // Add this where needed to display it when wanted

Props

  • enabledModes Do you only want the gallery mode or upload, or both ? Choose with this prop. enabledModes={["gallery", "upload"]}
  • galleryImages Array of images you will display in the gallery. Can either be a url, or an object with the following shape :
    const image = {
      src: "url",
      name: "imageName",
      credits: "imageCredits",
    };
  • canSelectSeveralImages : boolean to allow or not to select several image in the gallery.
  • globalOnSelectImages : Callback method that will be called each time when user validates images selection from gallery.
  • To setup a setter for a particular component, pass the setter in setOnValidationCallBack that you get from useImageManager hook. It will receive the array of selected images.
  • urlUpload : URL where image to upload will be sent.
  • axiosHeadersUpload : Axios headers you would like to pass when uploading, for auth purpose for example.
  • onSuccessUpload : Callback called when upload was successful. Could be a notification.
  • onFailureupload : Callback called when upload was failed. Could be a notification.
  • imageFields : Array of properties you would like your user to fulfill when uploading an image.
  • minWidthImageUpload : Minimum width of pixels of image that user can upload.

All react-image-crop props can be used to custom the crop feature. For example :

  • cropAspectRatio : Choose the ratio of how you want to crop the image.
  • All other are availables on the doc of the library.

Style

CSS can be customized. Pagination and upload inputs are handled through classic css files. import "react-image-manager/dist/style.css"; import "react-image-manager/dist/pagination.css"; import "react-image-crop/dist/ReactCrop.css";

Various

Gist on how to resize the image with sharp library, server side

TO DO

FIRST

  • Typescript ftw : add types everywhere and pass everything in .tsx

THEN

  • Refacto, code is awful rn omg
  • Allow more customization by user

HELP ME ?

  • Any idea is welcome, the project is here to live! Open an issue and feel welcome!
  • You can check the TODO.md file for suggestions
1.1.1

7 months ago

1.1.7

7 months ago

1.1.6

7 months ago

1.1.5

7 months ago

1.1.4

7 months ago

1.1.3

7 months ago

1.1.2

7 months ago

1.0.141

1 year ago

1.0.140

1 year ago

1.0.132

1 year ago

1.0.131

1 year ago

1.0.134

1 year ago

1.0.133

1 year ago

1.0.130

1 year ago

1.0.139

1 year ago

1.0.136

1 year ago

1.0.135

1 year ago

1.0.138

1 year ago

1.0.137

1 year ago

1.0.101

1 year ago

1.0.100

1 year ago

1.0.107

1 year ago

1.0.106

1 year ago

1.0.109

1 year ago

1.0.108

1 year ago

1.0.103

1 year ago

1.0.102

1 year ago

1.0.105

1 year ago

1.0.104

1 year ago

1.0.121

1 year ago

1.0.120

1 year ago

1.0.123

1 year ago

1.0.122

1 year ago

1.0.129

1 year ago

1.0.128

1 year ago

1.0.125

1 year ago

1.0.124

1 year ago

1.0.127

1 year ago

1.0.126

1 year ago

1.0.84

1 year ago

1.0.83

1 year ago

1.0.88

1 year ago

1.0.87

1 year ago

1.0.86

1 year ago

1.0.85

1 year ago

1.0.89

1 year ago

1.0.110

1 year ago

1.0.112

1 year ago

1.0.111

1 year ago

1.0.118

1 year ago

1.0.114

1 year ago

1.0.113

1 year ago

1.0.116

1 year ago

1.0.91

1 year ago

1.0.90

1 year ago

1.0.95

1 year ago

1.0.94

1 year ago

1.0.93

1 year ago

1.0.92

1 year ago

1.0.99

1 year ago

1.0.98

1 year ago

1.0.97

1 year ago

1.0.96

1 year ago

1.0.62

1 year ago

1.0.61

1 year ago

1.0.60

1 year ago

1.0.66

1 year ago

1.0.65

1 year ago

1.0.64

1 year ago

1.0.63

1 year ago

1.0.69

1 year ago

1.0.68

1 year ago

1.0.67

1 year ago

1.0.73

1 year ago

1.0.72

1 year ago

1.0.71

1 year ago

1.0.70

1 year ago

1.0.77

1 year ago

1.0.76

1 year ago

1.0.75

1 year ago

1.0.74

1 year ago

1.0.79

1 year ago

1.0.80

1 year ago

1.0.82

1 year ago

1.0.81

1 year ago

1.0.55

1 year ago

1.0.54

1 year ago

1.0.59

1 year ago

1.0.58

1 year ago

1.0.57

1 year ago

1.0.56

1 year ago

1.0.29

2 years ago

1.0.28

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.37

2 years ago

1.0.36

2 years ago

1.0.35

2 years ago

1.0.34

2 years ago

1.0.39

2 years ago

1.0.38

2 years ago

1.0.40

2 years ago

1.0.44

2 years ago

1.0.42

2 years ago

1.0.41

2 years ago

1.0.48

2 years ago

1.0.47

2 years ago

1.0.46

2 years ago

1.0.45

2 years ago

1.0.49

2 years ago

1.0.51

2 years ago

1.0.50

2 years ago

1.0.53

2 years ago

1.0.52

2 years ago

1.0.27

2 years ago

1.0.26

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

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.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago