Skip to content

Instantly share code, notes, and snippets.

@pranali333
Last active March 14, 2017 06:59
Show Gist options
  • Save pranali333/3ec55040c9ead9c1a2dbdb13761f8036 to your computer and use it in GitHub Desktop.
Save pranali333/3ec55040c9ead9c1a2dbdb13761f8036 to your computer and use it in GitHub Desktop.
Custom code to keep media description open while uploading media using rtMedia uploader
// Check if function does not exist.
if ( ! function_exists( 'rtmedia_wp_footer_open_title_and_desc_callback' ) ) {
/**
* Add script in the wp_footer that fire just after the media is added in the rtMedia up-loader
* By default it will open the title and description box of the media
*/
function rtmedia_wp_footer_open_title_and_desc_callback() {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
rtMediaHook.register( 'rtmedia_js_file_added', function( args ) {
if( typeof args == 'object' && typeof args[1] != 'undefined' && typeof args[1].id != 'undefined' ) {
var id = args[1].id;
var button_click = '#label_' + id;
setTimeout( function() {
if( jQuery( button_click ).length > 0 ){
jQuery( button_click ).trigger( 'click' );
}
}, 250 );
}
return true;
} );
});
</script>
<?php
}
}
add_action( 'wp_footer', 'rtmedia_wp_footer_open_title_and_desc_callback' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment