daily pastebin goal
58%
SHARE
TWEET

Untitled

a guest Sep 18th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. plupload only working with html5 in wordpress plugin
  2. wp_enqueue_script('plupload-all');
  3.    
  4. echo '<div class="uploader" id="symposium_activity_uploader" style="display:none">';
  5.   echo '<a id="pickfiles" href="#">Attach an image</a>';
  6.   echo '<div id="progressbar"></div>';
  7. echo '</div>';
  8. echo '<div id="symposium_filelist" class="cb"></div>';
  9.    
  10. // Settings ////////////////////////////////////////////////
  11. var uploader = new plupload.Uploader({
  12.     runtimes : 'html5,flash,silverlight,gears,html4',
  13.     flash_swf_url : '/wp-includes/js/plupload/plupload.flash.swf',
  14.     silverlight_xap_url : '/wp-includes/js/plupload/plupload.silverlight.xap',
  15.     browse_button : 'pickfiles',
  16.     max_file_size : '1mb',
  17.     urlstream_upload : true,
  18.     multipart : true,
  19.     multi_selection: false,
  20.     resize : {width : 300, height : 300, quality : 90},
  21.     container : 'symposium_activity_uploader',
  22.     url : '/wp-content/plugins/wp-symposium/ajax/dothisnext.php',
  23.     filters : [ {title : "Image files", extensions : "jpg,gif,png"} ]
  24. });
  25.  
  26. uploader.bind('Init', function(up, params) {
  27.     jQuery('#symposium_filelist').html("<div>Current runtime: " + params.runtime + "</div>");
  28.     jQuery('#symposium_activity_uploader').show();
  29. });
  30.  
  31. // Init ////////////////////////////////////////////////////
  32. uploader.init();
  33.  
  34. // Selected Files //////////////////////////////////////////
  35. uploader.bind('FilesAdded', function(up, files) {
  36.     jQuery.each(files, function(i, file) {
  37.         jQuery('#symposium_filelist').append('<div class="addedFile" id="' + file.id + '">' + file.name + '</div>');
  38.     });
  39.     up.refresh();
  40.     uploader.start();
  41. });
  42.  
  43. // Error Alert /////////////////////////////////////////////
  44. uploader.bind('Error', function(up, err) {
  45.     alert("Error: " + err.code + ", Message: " + err.message + (err.file ? ", File: " + err.file.name : "") + "");
  46.     up.refresh();
  47. });
  48.  
  49. // Progress bar ////////////////////////////////////////////
  50. uploader.bind('UploadProgress', function(up, file) {
  51.     var progressBarValue = up.total.percent;
  52.     jQuery('#progressbar').fadeIn().progressbar({
  53.         value: progressBarValue
  54.     });
  55.     jQuery('#progressbar .ui-progressbar-value').html('<span class="progressTooltip">' + up.total.percent + '%</span>');
  56. });
  57.  
  58. // Close window after upload ///////////////////////////////
  59. uploader.bind('UploadComplete', function() {
  60.     jQuery('.uploader').fadeOut('slow');
  61. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top