WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using new 3.5 media uploader in my theme frontend (base on this example). It is very simple when you want to do something with images after the 'Select' button is pressed:

file_frame.on('select', function() {
    // Get all attachments
    var attachments = file_frame.state().get('selection').toJSON();

    // Do stuff with attachments

But what if I want to do something with attachments just after they were upload? Something like:

file_frame.on('upload', function() {
    // Do stuff with attachments

I didn't find anything useful in 'wp-includes/js/media-models.js' or 'wp-includes/js/media-views.js'.

I have tried to attach a lot of events found in those files:

'add', 'url', 'select', 'ready', 'escapeHandler', 'keydown', 'attach', 'open', 'close', 'escape', 'recordTab', 'updateIndex', 'activate', 'dismiss', 'remove', 'reset', 'uploading', 'deactivate', 'create', 'render', 'change:content', 'scan', 'prepare', 'content:render:upload', 'content:render', 'content', 'updateIndex', 'recordTab', 'change:uploading', 'finish', 'done', 'upload', 'uploaded', 'save', 'saved','change:compat', 'compat'

But all these events fires not when I need this.


share|improve this question
You could hook into the add_attachment action: codex.wordpress.org/Plugin_API/Action_Reference/add_attachment – MikeNGarrett Jan 13 '14 at 2:13

There is a FileUploaded event being fired in wp-includes/js/plupload/wp-plupload.js.

Alternatively (and propably the better way) you may want extend wp.Uploader with your own success callback .


    $.extend( wp.Uploader.prototype, {
        success : function( file_attachment ){
            console.log( file_attachment );
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.