Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function ($) {
- $.fn.imgLoader = function (options) {
- var settings = $.extend( {
- 'target' : $('.show'),
- 'width' : 'auto',
- 'height' : 'auto'
- }, options);
- this.each(function () {
- $(this).change(function () {
- var reader = new FileReader();
- // Closure to capture the file information.
- reader.onload = (function(theFile) {
- return function(e) {
- settings.target.html('<img src="'+e.target.result+'" width="'+settings.width+'" height="'+settings.height+'" />');
- };
- })(this.files[0]);
- // Read in the image file as a data URL.
- reader.readAsDataURL(this.files[0]);
- });
- });
- };
- })(jQuery);
Add Comment
Please, Sign In to add comment