Home › Support › Image Store › Adding custom column to image
Tagged: custom image column
-
AuthorPosts
-
April 28, 2013 at 1:19 pm #52840armandsdzParticipant
Hi!
Thanks for great plugin!
I have one question- has anyone implemented a custom field/column for separate images?
I would need to add a custom field for every image to be able to indicate which persons are seen on the image.
I imagine that persons could be defined as Categories and then I could use check-boxes to create a relationship between image and Category. Perhaps there is a better way.Can this be done using some hooks and in what direction do I dig?
I see that there is a hook ims_image_custom_column..but I don’t really understand how to use it for this purpose.Many Thanks!
Armands
May 4, 2013 at 12:40 am #52901Xpark MediaKeymasteryou 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
May 9, 2013 at 1:23 pm #53014armandsdzParticipantThanks!
This was very helpful! -
AuthorPosts
- You must be logged in to reply to this topic.