manage_media_custom_columnaction-hookWP 2.5.0

Fires for each custom column in the media table. Allows you to specify the value to display in a custom table column.

Custom columns are registered with the manage_media_columns filter.

Usage

add_action( 'manage_media_custom_column', 'wp_kama_manage_media_custom_column_action', 10, 2 );

/**
 * Function for `manage_media_custom_column` action-hook.
 * 
 * @param string $column_name Name of the custom column.
 * @param int    $post_id     Attachment ID.
 *
 * @return void
 */
function wp_kama_manage_media_custom_column_action( $column_name, $post_id ){
	// action...
}
$column_name(string)
The name of the custom column currently being processed in the table.
$post_id(integer)
The attachment (media file) ID.

Examples

#1 Add a column and display media file IDs in it

GitHub
<?php

add_filter( 'manage_media_columns', 'add_my_column_in_media_table' );
add_action( 'manage_media_custom_column', 'fill_my_column_in_media_table', 10, 2 );

/**
 * Создает новую колонку.
 *
 * @param array $columns
 *
 * @return array
 */
function add_my_column_in_media_table( $columns ) {
    // Добавим хук, который в футере выведет стили для нашей колонки
    add_action( 'admin_footer', 'add_my_column_in_media_table_css' );

    // Добавим колонку в начало
    return [ 'id-image' => 'ID' ] + $columns;
}

/**
 * Заполняет колонку данными.
 *
 * @param string $colname
 * @param int    $post_id
 */
function fill_my_column_in_media_table( $colname, $post_id ) {
    if ( $colname === 'id-image' ) {
        echo (int) $post_id;
    }
}

/**
 * Выводит на экран стили для колонки "ID".
 */
function add_my_column_in_media_table_css() {
    ?>
    <style type="text/css">
        #id-image {
            width: 40px;
        }
    </style>
    <?php
}

Changelog

Since 2.5.0 Introduced.

Where the hook is called

WP_Media_List_Table::column_default()
manage_media_custom_column
wp-admin/includes/class-wp-media-list-table.php 743
do_action( 'manage_media_custom_column', $column_name, $post->ID );

Where the hook is used in WordPress

Usage not found.