# List the Generated Sizes of Each Image

> Adds a box to the image edit screen listing every size WordPress generated for it, with dimensions, file size and a link to open each one, to check crops and spot missing sizes.

- Type: PHP
- Runs: Admin only
- Category: [Media](https://wpide.com/library/category/media/)
- Tags: image-sizes, thumbnails, media-library
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/media-generated-sizes-box/

## Code

```php
add_action( 'add_meta_boxes_attachment', function ( $post ) {
    if ( ! wp_attachment_is_image( $post ) ) {
        return;
    }
    add_meta_box( 'wpide-image-sizes', 'Generated sizes', function ( $post ) {
        $meta  = wp_get_attachment_metadata( $post->ID );
        $sizes = $meta['sizes'] ?? array();
        $base  = trailingslashit( dirname( (string) wp_get_attachment_url( $post->ID ) ) );

        if ( ! $sizes ) {
            echo '<p>No extra sizes were generated.</p>';
            return;
        }

        echo '<table class="widefat striped"><thead><tr><th>Size</th><th>Dimensions</th><th>File size</th></tr></thead><tbody>';
        foreach ( $sizes as $name => $size ) {
            printf(
                '<tr><td><a href="%s" target="_blank" rel="noopener">%s</a></td><td>%d &times; %d</td><td>%s</td></tr>',
                esc_url( $base . $size['file'] ),
                esc_html( $name ),
                (int) $size['width'],
                (int) $size['height'],
                ! empty( $size['filesize'] ) ? esc_html( size_format( $size['filesize'] ) ) : '&ndash;'
            );
        }
        echo '</tbody></table>';
        $missing = array_diff( array_keys( wp_get_registered_image_subsizes() ), array_keys( $sizes ) );
        if ( $missing ) {
            echo '<p class="description">Not generated: ' . esc_html( implode( ', ', $missing ) ) . ' (the original may be too small).</p>';
        }
    }, 'attachment', 'normal', 'low' );
} );
```

## Notes

Sizes registered after the image was uploaded will be missing until you regenerate it.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "List the Generated Sizes of Each Image" 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/
