On searching for a solution, I found the following codes to add col on media page:
add_filter ( "manage_upload_columns", 'upload_columns' );
add_action ( "manage_media_custom_column", 'media_custom_columns' , 0, 2 );
The result is close to what I want, but I need to implement it on thickbox gallery tab-- I want to add an "Include" checkbox column for the media items.
How can I achieve this?
[update]
This checkbox would serve as the include part in the gallery shortcode [gallery include="23,39,45"]
.
But, the shortcode is not written in the post content. The gallery is added for each post by a theme template.
[update] To save the ids we get from brasofilo's scripts, I added name="include_ids" in the shortcode line and added this:
add_action( 'edit_attachment', array ($this,'save_to_parent_meta' ));
function save_to_parent_meta(){
if ( isset($_POST['include_ids']) && !empty($_POST['include_ids']) ) {
check_admin_referer('media-form');
update_post_meta( $_REQUEST['post_id'],'include_ids',$_POST['include_ids']);
}
}
This will save the ids to parent post's meta if 'includes_ids' filed is not empty. Nearly perfect. But, when the tab is loaded, the include_ids field is empty, and all checkbox is unchecked. Users might think they need to check again even if they don't want to make change.
[gallery include="23,39,45"]
built automatically based on the user selection through checkboxes? Codex reference: codex.wordpress.org/Gallery_Shortcode