Getting ID from ajax response of async-upload.php

I could but i really don’t want to post the work of others here, even if it’s open source code. Rilwis Meta Box Class has a plupload field, which has a custom upload handler. If you mind to take a look: https://github.com/rilwis/meta-box resp: https://github.com/rilwis/meta-box/blob/master/inc/fields/plupload-image.php#L31 The answer is there. This code,or at least the idea, gives … Read more

Plupload in metabox – AJAX action not working in Class

Aha, the problem as that I was calling the wp_ajax_plupload_action from within my page conditional check like so: function __construct() { global $pagenow; $pages = array(‘post.php’, ‘post-new.php’); if (in_array($pagenow, $pages)) : add_action(‘add_meta_boxes’, array($this, ‘dhf_video_meta_box’)); add_action(‘admin_print_scripts’, array($this, ‘video_meta_js’)); add_action(‘admin_head’, array($this, ‘plupload_admin_head’)); add_action(‘admin_print_scripts’, array($this, ‘video_meta_css’)); add_action(‘wp_ajax_plupload_action’, array($this, ‘plupload_action’)); endif; } You don’t want to do it like … Read more

post_id missing from the wp-admin file upload request

Ok this seems to have fixed it: function wp_plupload_include_attachment_id( $params ) { global $post_ID; if ( isset( $post_ID ) ) $params[‘post_id’] = (int) $post_ID; return $params; } add_filter( ‘plupload_default_params’, ‘wp_plupload_include_attachment_id’ ); This preprocesses the uploader $params and makes sure the post_id is included. Taken from here: https://core.trac.wordpress.org/attachment/ticket/22085/media.php.patch

Add/change multipart_params parameter when uploading post image

To send a customer data to the server, do the following customFileFrame.uploader.options.uploader.params.yourCustomProperty = ‘yourCustomValue’; Where: yourCustomProperty – parameter name yourCustomValue – parameter value processing data from the server add_action(‘add_attachment’, array($this, ‘addAttachmentParama’)); public function addAttachmentParama($post_id){ if (isset($_REQUEST[‘yourCustomProperty’]) && isset($_REQUEST[‘action’]) && ‘upload-attachment’ == $_REQUEST[‘action’]) { update_post_meta($post_id, ‘yourCustomProperty’, $_REQUEST[‘yourCustomProperty’]); } } Mini Plugin for example <?php /* Plugin … Read more

Add inline uploader to plugin option page

Okay, here is what I came up with: It’s all about using the plupload library that comes shipped with WP. 1. Add a <div> to your plugin’s option page that later becomes the drag’n’drop area <div class=”your-plugin-uploader multiple”> <input id=”your-plugin-uploader-button” type=”button” value=”<?php esc_attr_e( ‘Select Files’ ); ?>” class=”your-plugin-uploader-button button”> <span class=”ajaxnonce” id=”<?php echo wp_create_nonce( __FILE__ … Read more

Plupload Intergration in a meta-box?

My specifically how to collect a response from the plUpload jQuery object once it has uploaded the media that you want and how one would use the same functionality in a meta box to create a gallery? There’s a specific file that handles this functionality: /wp-includes/js/plupload/handlers.dev.js. This file contains all of the hooks and triggers … Read more