<?php
add_filter('manage_upload_columns', 'bp_add_column_file_size');
add_action('manage_media_custom_column', 'bp_column_file_size', 10, 2);
add_action('admin_head', 'bp_add_media_styles');
function bp_add_column_file_size($columns)
{
$columns['bpFilesize'] = __('File Size');
return $columns;
}
function bp_column_file_size($column_name, $media_item)
{
if ('bpFilesize' != $column_name || !wp_attachment_is_image($media_item)) {
return;
}
$bpFilesize = filesize(get_attached_file($media_item));
$bpFilesize = size_format($bpFilesize, 2);
echo $bpFilesize;
}
function bp_add_media_styles()
{
echo '<style>.column-bpFilesize {width: 50px;}</style>';
}