Bring Your Business to Life › Support › Image Store › Adding custom column to image › Reply To: Adding custom column to image
May 4, 2013 at 12:40 am #52901
Keymaster
you can use “ims_image_custom_column” to add the new field text/area/check box this will just add the field to enter the value. But first you need to register the column.
function image_store_gallery_screen_columns(){ global $ImStore; $ImStore->columns['new_column'] = __('new field title'); }add_action( 'wp_loaded', 'image_store_gallery_screen_columns' ), 20 );
then you return the html markup for the field, for a single image
function image_store_add_new_field( $column_id, $id, $data, $attch ){ if( $column_id == 'new_column') return "html markup"; }add_filter('ims_image_custom_column', 'image_store_add_new_field', 20, 3)
Use the “save_post” action to save the data when the user saves the gallery. Run some validation like
function image_store_save_field_data( $postid, $post ) { if ( !current_user_can( 'ims_add_galleries' ) || $post->post_type != 'ims_gallery' || empty( $_POST['post_ID'] ) ) return $postid; //do something }add_filter('save_post', 'image_store_save_field_data', 20, 2)
to display the value you can use “ims_image_tag_meta” or “ims_image_tag” filters