I'm trying to display the description of each file on the media library browser screen. I've found some code that adds a filename column, but I'm trying to modify it so that it will display the description field instead of the filename. I'm not quite sure of how to do this. The description column displays, but doesn't actually show the description data for each file. I think I'm getting hung up on this line:
echo substr(strrchr($meta['attachment_content'], '/' ), 1);
but it's possible that there are other issues.
Below is the full code:
function description_column($cols) {
$cols["description"] = "Description";
return $cols;
}
function description_value($column_name, $id) {
$meta = wp_get_attachment_metadata($id);
echo substr(strrchr($meta['attachment_content'], '/' ), 1);
}
function description_column_sortable($cols) {
$cols["description"] = "name";
return $cols;
}
function hook_new_media_columns() {
add_filter('manage_media_columns', 'description_column');
add_action('manage_media_custom_column', 'description_value', 10, 2);
add_filter('manage_upload_sortable_columns', 'description_column_sortable');
}
add_action('admin_init', 'hook_new_media_columns');
Thanks for your help!