Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jQuery(function($){
- //alert($.fn.jquery)
- var siteurl = $('div#new_talk_container').find('input#siteurl').attr('value');
- var themeurl = $('div#new_talk_container').find('input#themeurl').attr('value');
- var myUploader = new plupload.Uploader({
- runtimes: 'html5,flash',
- browse_button: 'browse_file', // id of the browser button
- max_file_size: '5mb',
- unique_names: true,
- file_data_name: 'filedata',
- filters : [
- {
- title : "Allowed files",
- extensions : "jpg,gif,png"
- },
- ],
- multiple_queues: false,
- multipart: true, // <- this is important because you want
- multi_selection:true,
- // to pass other data as well
- url: ajax_object.ajaxurl,
- });
- myUploader.init();
- myUploader.bind('FilesAdded', function(up, files){
- $('#browse_file').text('Selected: ' + files[0].name);
- // alert(files[0].toSource());
- // do a console.log(files) to see what file was selected...
- });
- // before upload starts, get the value of the other fields
- // and send them with the file
- myUploader.bind('BeforeUpload', function(up) {
- myUploader.settings.multipart_params = {
- action: 'action_insert_newtalk',
- talk_text: $('div#new_talk_container').find('#newTalkTxt').attr('value'),
- talk_author_id: $('div#current_user_id').find('input#current_user_id').attr('value')
- };
- });
- // equivalent of the your "success" callback
- myUploader.bind('FileUploaded', function(up, file, ret){
- var $response = $(ret.response);
- var brandNewTalk = $response.filter('#brandNewTalk').html();
- if(brandNewTalk) {
- setTimeout(function(){
- $('div#newTalkAfter').append(brandNewTalk);
- $('div#newTalkAfter').fadeIn('slow');
- }, 500);
- $('#newTalkTxt').val('');
- }
- });
- // trigger submission when this button is clicked
- $('div#publish_new_talk').on('click', function(e) {
- myUploader.start();
- e.preventDefault();
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment