Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Add Media Library Column: File Size
// Add Media Library Column: File Size
// Need help:
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');
// Create the column
function bp_add_column_file_size($columns)
$columns['bpFilesize'] = __('File Size');
return $columns;
// Display the file size
function bp_column_file_size($column_name, $media_item)
if ('bpFilesize' != $column_name || !wp_attachment_is_image($media_item)) {
$bpFilesize = filesize(get_attached_file($media_item));
$bpFilesize = size_format($bpFilesize, 2);
echo $bpFilesize;
// Format the column width with CSS
function bp_add_media_styles()
echo '<style>.column-bpFilesize {width: 10px;}</style>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment