# File Size and Dimensions Columns in the Media Library

> Adds File Size and Dimensions columns to the Media Library list view, making heavy images easy to spot.

- Type: PHP
- Runs: Admin only
- Category: [Media](https://wpide.com/library/category/media/)
- Tags: media, columns, file-size
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/media-file-size-column/

## Code

```php
add_filter( 'manage_media_columns', function ( $columns ) {
    $columns['wpide_filesize']   = 'File Size';
    $columns['wpide_dimensions'] = 'Dimensions';

    return $columns;
} );

add_action( 'manage_media_custom_column', function ( $column, $attachment_id ) {
    $meta = wp_get_attachment_metadata( $attachment_id );

    if ( 'wpide_filesize' === $column ) {
        $bytes = ! empty( $meta['filesize'] ) ? (int) $meta['filesize'] : 0;

        if ( ! $bytes ) {
            $file  = get_attached_file( $attachment_id );
            $bytes = ( $file && file_exists( $file ) ) ? (int) filesize( $file ) : 0;
        }

        echo $bytes ? esc_html( size_format( $bytes, 1 ) ) : '&mdash;';
    } elseif ( 'wpide_dimensions' === $column ) {
        echo ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) ? esc_html( $meta['width'] . ' x ' . $meta['height'] ) : '&mdash;';
    }
}, 10, 2 );
```

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "File Size and Dimensions Columns in the Media Library" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
