# Recent Uploads Dashboard Widget

> Adds a dashboard widget with thumbnails of the 12 most recently uploaded images and files, each linking to its edit screen, so you can review new media quickly.

- Type: PHP
- Runs: Admin only
- Category: [Dashboard](https://wpide.com/library/category/dashboard/)
- Tags: dashboard-widget, media, uploads
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/dash-recent-uploads-widget/

## Code

```php
add_action( 'wp_dashboard_setup', function () {
    if ( ! current_user_can( 'upload_files' ) ) {
        return;
    }

    wp_add_dashboard_widget( 'wpide_recent_uploads', 'Recent uploads', function () {
        $files = get_posts( array(
            'post_type'      => 'attachment',
            'post_status'    => 'inherit',
            'posts_per_page' => 12,
            'no_found_rows'  => true,
        ) );

        if ( ! $files ) {
            echo '<p>No uploads yet.</p>';
            return;
        }

        echo '<div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(70px,1fr));gap:6px">';
        foreach ( $files as $file ) {
            printf(
                '<a href="%s" title="%s" style="display:block;aspect-ratio:1;overflow:hidden;border-radius:3px;background:#f0f0f1">%s</a>',
                esc_url( get_edit_post_link( $file->ID ) ),
                esc_attr( get_the_title( $file ) ),
                wp_get_attachment_image( $file->ID, 'thumbnail', true, array( 'style' => 'width:100%;height:100%;object-fit:cover', 'alt' => get_the_title( $file ) ) )
            );
        }
        echo '</div>';
        printf( '<p><a href="%s">Open the Media Library</a></p>', esc_url( admin_url( 'upload.php' ) ) );
    } );
} );
```

## Notes

Non-image files show their file type icon.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Recent Uploads Dashboard Widget" 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/
