Insert Image automatically when upload finishes wordpress media uploader

The hook for doing stuff after an upload is the reset event on wp.Uploader.queue triggered by the pluploader when it’s finished (see line 249 in “wp-includes/js/plupload/wp-plupload.js”). Here’s one hack to use this to do an auto-insert after an upload:

function wpse167143_admin_footer() {
?>
<script>
jQuery( document ).ready(function() {
    typeof wp.Uploader !== 'undefined' && wp.Uploader.queue.on( 'reset', function () {
        // From the primary toolbar (".media-toolbar-primary")
        // get the insert button view (".media-button-insert")
        // and execute its click (as specified in its options).
        wp.media.frame.toolbar.get('primary').get('insert').options.click();
    } );
});
</script>
<?php
}
add_action( 'admin_footer' , 'wpse167143_admin_footer' );