Adding custom column to image

HomeSupportImage StoreAdding custom column to image

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #52840
    armandsdz
    Participant

    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

    #52901
    Xpark Media
    Keymaster

    @armandsdz,

    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

    #53014
    armandsdz
    Participant

    Thanks!
    This was very helpful!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.