Skip to content

Instantly share code, notes, and snippets.

@mauryaratan
Created December 14, 2012 06:08
Show Gist options
  • Select an option

  • Save mauryaratan/4283059 to your computer and use it in GitHub Desktop.

Select an option

Save mauryaratan/4283059 to your computer and use it in GitHub Desktop.

Revisions

  1. mauryaratan created this gist Dec 14, 2012.
    22 changes: 22 additions & 0 deletions WP3.5 Media Uploader
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    jQuery(document).ready(function($){
    var _custom_media = true,
    _orig_send_attachment = wp.media.editor.send.attachment;
    $('.stag-metabox-table .button').click(function(e) {
    var send_attachment_bkp = wp.media.editor.send.attachment;
    var button = $(this);
    var id = button.attr('id').replace('_button', '');
    _custom_media = true;
    wp.media.editor.send.attachment = function(props, attachment){
    if ( _custom_media ) {
    $("#"+id).val(attachment.url);
    } else {
    return _orig_send_attachment.apply( this, [props, attachment] );
    };
    }
    wp.media.editor.open(button);
    return false;
    });
    $('.add_media').on('click', function(){
    _custom_media = false;
    });
    });