Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PLUpload Demo
<?php
/*
Plugin Name: PLUpload Demo
Plugin URI: http://wordpress.org/
Description: This is a demo that uses core PLUpload.
Author: Boro Sitnikovski
Version: 1.0
Author URI: http://bor0.wordpress.com/
*/
class PLUpload_Demo {
public function init() {
wp_enqueue_script( 'plupload-all' );
}
public function __construct() {
add_shortcode( 'plupload', array( $this, 'render' ) );
add_action( 'init', array( $this, 'init' ) );
}
public function render() {
?>
<div id="uploader">
<a id="browse" href="#">Upload</a>
</div>
<script type="text/javascript">
var uploader = new plupload.Uploader({
runtimes : 'html5,flash,silverlight,gears,html4',
flash_swf_url : '/wp-includes/js/plupload/plupload.flash.swf',
silverlight_xap_url : '/wp-includes/js/plupload/plupload.silverlight.xap',
browse_button : 'browse',
max_file_size : '1mb',
urlstream_upload : true,
multipart : true,
multi_selection: false,
resize : {width : 300, height : 300, quality : 90},
container : 'uploader',
url : '/',
filters : { mime_types: [ {title : "Image files", extensions : "jpeg,jpg,gif,png"} ] }
});
uploader.init();
</script>
<?php
}
}
new PLUpload_Demo();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment