npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cherrypulp/image-upload

v1.0.9

Published

Image upload and crop component made easier using AntD.

Downloads

16

Readme

Image Upload And Crop using Ant Design

Image upload and crop component made easier using AntD.

Latest Version on NPM npm Software License

Demo

A demo is available here : https://codesandbox.io/s/image-upload-rqfis7?file=/src/App.js

Getting started

This package works inside an Ant Design Project and assume that you have loaded the Ant Design Style.

Here is the getting started for the AntD Setup : https://ant.design/docs/react/getting-started. You can also download the minimal CSS to import if you don't fully load Ant Design : https://github.com/nanxiaobei/antd-img-crop#styles.

In your project just make :

yarn add @cherrypulp/image-upload 
# or
npm i @cherrypulp/image-upload --save

Then :

import {ImageUpload} from "@cherrypulp/image-upload";

const MyComponent = () => {
  return (<>
    <ImageUpload action={"/api/upload"} src={"https://dummyimage.com/600x400/000/fff"} />
    {-- Exemple using a banner with a width 3x larger than height @see https://www.websightdesign.com/helpdesk/article?category=12000001079&folder=5000134798&article=5000638101  --}
    <ImageUpload action={"/api/upload"} aspect={3} src={"https://dummyimage.com/600x400/000/fff"} />
  </>);
}

export default MyComponent;

Fully controlled example

This package give you access to all the properties and features of Ant Img Crop and Ant Uploader.

Here is a working example on how to override default behavior :

https://codesandbox.io/s/image-upload-rqfis7?file=/src/App.js

Properties

| Properties | Type | Default | Description | |---------------|:-----------------------:|:---------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | action * | string | - | Action where the image will be posted | | src* | string | - | Src of the current picture | | defaultSrc | string | - | Default src image file if null | | name | string | "image" | default name used to post the picture in the api (default = "image") | | aspect | number | 1 | Ratio of the picture (default = 1 = square) | | cropOptions | Object | { rotate: true } | Default cropOptions @see https://github.com/nanxiaobei/antd-img-crop#props | | uploadOptions | Object | { listType : "picture", onPreview: () => {} } | AntD Upload options @see https://ant.design/components/upload/#components-upload-demo-crop-image | | uploadButton | React.ReactNode or null | - | You can override it with a React Component | | maxSize | number | 10 | Max file size in Mo (default = 10mo max) |

Digging deeper

You can get full documentation or check our complete example :

To dos :

[x] Testing e2e

Any helps wanted !

License

MIT

Treeware license

This package is also a Treeware.

If you use it in production, then we kindly ask buy the world a tree to thank us for our work.

By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

Support us

Support us on Open Collective or buy us a Tree :