Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

spartan-multi-image-picker

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spartan-multi-image-picker

A Jquery multi image picker with preview (with madness)

  • 1.0.1-rc.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17
increased by54.55%
Maintainers
1
Weekly downloads
 
Created
Source

spartan-multi-image-picker

npm

This plugin enable you to upload multiple files on a html form without giving your dummy user a pain in the ass to hold their Ctrl keyboard for non ajax upload file.

img

Installation

Download this package or install via bower bower install spartan-multi-image-picker

Include JQuery first, and this plugin after that like so.

<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="dist/js/spartan-multi-image-picker-min.js"></script>

Create an element where do you want to activate this input file.

<div class="row">
	<div id="coba"></div>
</div>

Activate this plugin.

$("#coba1").spartanMultiImagePicker({
	fieldName:   'fileUpload[]'
});

The fieldName is your field name that will appended as input type file to you html.

All Properties

This is what you can custom when you call this plugin.

PropertyTypeExample
fieldNameStringfileUpload[] or fileUpload for single image
maxCountNumber1, 2 remove for unlimited count
rowHeightString200px
groupClassNameStringcol-md-4 col-sm-4 col-xs-6
allowedExtString`png
placeholderImageObject with image and width properties{ image: 'placeholder.png', width: '100%'}
maxFileSizeNumber (in kb)40000

Callback

CallbackDescription
onAddRowCalled on a new field appear
onRenderedPreviewCalled on image rendered as a preview
onRemoveRowCalled on user click the remove button for each field
onExtensionErrCalled on extension didn't match as allowedExtension
onSizeErrCalled on image size is more than maxFileSize prop

Full customize example:

$("#coba").spartanMultiImagePicker({
	fieldName:        'fileUpload[]',
	maxCount:         5,
	rowHeight:        '200px',
	groupClassName:   'col-md-4 col-sm-4 col-xs-6',
	allowedExt:       'png|jpg',
	placeholderImage: {
	    image: 'placeholder.png',
	    width: '100%'
	},
	onAddRow:       function(){
		console.log('add new row');
	},
	onRenderedPreview : function(){
		console.log('preview rendered');
	},
	onRemoveRow : function(){
		console.log('remove row');
	},
	onExtensionErr : function(){
		console.log('extension error');
		alert('Please only input png or jpg type file');
	},
	onSizeErr : function(){
		console.log('file size too big');
		alert('File size too big');
	}
});

Keywords

FAQs

Package last updated on 30 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc