Aubrey Portwood

How to Automatically Insert Into Post when uploading Media in WordPress

| Permalink

This is how I did it:

First, in your plugin, force the basic uploader. If you want the flash uploader, sorry.

add_filter( 'flash_uploader', '_force_html_uploader' );

function _force_html_uploader( $flash ) {
    remove_action('post-html-upload-ui', 'media_upload_html_bypass' );
    return false;

Then tell WP to put a JavaScript in the Media Uploader’s <head>:

add_action('media_upload_tabs', '_media_upload_auto_insert_js');

function _media_upload_auto_insert_js(){

Then, in that JavaScript file, when the page is loaded with the button to Insert Into Post, click it for them!


    if(jQuery(".savesend input")){
        jQuery(".savesend input").click();