This time I will share jQuery Plugin and tutorial about Highly Customizable Image Uploader Plugin – jQuery Imagify, hope it will help you in programming stack.
Imagify is a lightweight yet highly customizable image uploader with quality control, thumbnail preview, custom label and much more.
More features:
- Allows you to set the min/max dimension.
- Allows you to set the min/max image size.
- Allows you to restrict the file extension.
- Error handling.
- Works with the native file input.
How to use it:
1. Download & unzip the plugin and then include the Imagify plugin’s files on the webpage which has jQuery library installed.
1 |
< link href = "/path/to/imagify.css" rel = "stylesheet" > |
2 |
< script src = "/path/to/jquery.min.js" ></ script > |
3 |
< script src = "/path/to/imagify.js" ></ script > |
2. Create a container element to hold the image uploader.
1 |
< div id = "example" ></ div > |
3. Attach the function to the container element to initialize a basic image uploader.
2 |
$( '#example' ).imagify(); |
4. Config the image uploader using the following data-OPTION
attributes:
- data-min-file-size: min file size (mb)
- data-max-file-size: max file size
- data-max-width: max width (px)
- data-min-width: min width
- data-max-height: max height
- data-min-height: min height
- data-allowed-file-extensions: allowed file extensions
5. You can also pass these options via JavaScript:
01 |
$( '#example' ).imagify({ |
05 |
maxSizeErrorMessage: 'Imagify : Max size error !' , |
06 |
minSizeErrorMessage: 'Imagify : Min size error !' , |
12 |
dimensionErrorMessage: 'Imagify : Dimension error' , |
14 |
allowedExt: 'jpg jpeg png' , |
15 |
allowedExtErrorMessage: 'Imagify : Not allowed image extension !' |
6. More customization options:
01 |
$( '#example' ).imagify({ |
04 |
style: 'border: 1px solid #ccc;' , |
13 |
chooseText: "Choose Image" , |
14 |
changeFileText: "Change Image" , |
7. Possible events to handle the image selection & errors.
01 |
$( '#example' ).imagify({ |
03 |
onInit: function (elm) { |
07 |
onSuccess: function (elm,source) { |
11 |
onError: function (errorId) { |
15 |
onDimensionError: function (file) { |
19 |
onMinSizeError: function (file) { |
23 |
onMaxSizeError: function (file) { |
27 |
onAllowedExtError: function (file) { |
This awesome jQuery plugin is developed by soysaltan. For more Advanced Usages, please check the demo page or visit the official website.