Add File Size Column to Media Library
-
Hi, firstly I would like to say I love this plugin – already it has replaced a number of separate plugins on my site.
However, I do have a suggestion, that being to show the file size for each item uploaded to the Media Library.
See below cod that I normally add to my functions.php file within my child theme:
// Add Media Library Column: File Size /* ------------------------------------- */ add_filter('manage_upload_columns', 'ctm_add_column_file_size'); add_action('manage_media_custom_column', 'ctm_column_file_size', 10, 2); add_action('admin_head', 'ctm_add_media_styles'); // Create the column function ctm_add_column_file_size($columns) { $columns['ctmFilesize'] = __('File Size'); return $columns; } // Display the file size function ctm_column_file_size($column_name, $media_item) { if ('ctmFilesize' != $column_name || !wp_attachment_is_image($media_item)) { return; } $ctmFilesize = filesize(get_attached_file($media_item)); $ctmFilesize = size_format($ctmFilesize, 2); echo $ctmFilesize; } // Format the column width with CSS function ctm_add_media_styles() { echo '<style>.column-ctmFilesize {width: 60px;}</style>'; } /* ------------------------------------- */
Hopefully this can be added in an update.
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Add File Size Column to Media Library’ is closed to new replies.