Skip to content

Instantly share code, notes, and snippets.

@enriclluelles
Created November 28, 2011 16:40
Show Gist options
  • Save enriclluelles/1401020 to your computer and use it in GitHub Desktop.
Save enriclluelles/1401020 to your computer and use it in GitHub Desktop.
Uploads.setup = function (options) {
var defaults = {
runtimes: 'html5, flash, html4',
url: '/',
browse_button : 'pickfiles',
container : 'container',
max_file_size : '10mb',
filters : [
{title : "Image files", extensions : "jpg,jpeg,gif,png"}
],
resize : {width : 320, height : 240, quality : 90},
headers: {
'X-CSRF-Token': $('meta[name=csrf-token]').attr('content')
}
};
settings = $.extend(defaults, options);
var uploader = new plupload.Uploader(settings);
uploader.init();
uploader.bind('FilesAdded', function(up, files) {
uploader.start();
});
uploader.bind('FileUploaded', function(up, file, response) {
var presponse = $.parseJSON(response.response);
var view;
if (!presponse.error) {
view = Views.render('accommodation_picture_thumb', presponse);
$('#accommodation_pictures').append(view);
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment