• Skip to primary navigation
  • Skip to main content
OsomCode

OsomCode

Awesome code tutorials for WordPress and Genesis

  • Subscribe
  • My account
    • Edit profile
    • Favorites
    • Update credit card
  • Login

Display size and dimensions in WordPress media library

Discover in this tutorial how to display in the WordPress media library a column that shows the size and dimensions of the images.

The WordPress media library is one of the sections that could use a redesign. Indeed, there are some new features (such as categorization) that looks like they will arrive in WordPress 6.5.

But in the meantime, in this tutorial I’m going to explain how you can add a couple of new columns that display both the files size and dimensions in the library.

In addition, the size column allows you to sort the files from larger to smaller. This is especially interesting for deleting or optimizing images (or other types of media).

This would be the final result:

WordPress media library showing size and dimensions
WordPress media library showing size and dimensions

Let’s see how to achieve this.

Snippet to add to the media library columns that show the size and resolution of the images

Add the following code snippet to your functionality plugin:

To see this and another 1097 code snippets of this website, login or subscribe here.

In the code above you use several hooks, specifically:

Action hooks:

  • added_post_meta
  • manage_media_custom_column
  • pre_get_posts

Filters:

  • manage_media_columns
  • manage_upload_sortable_columns
  • manage_upload_columns

And as a result you add a size column (which allows you to sort from larger to smaller or vice versa) and another one with the resolution of the images.

If you prefer to have this code separate you can follow the tutorial to create a plugin.

Conclusions

Do you want to get at a glance the images size or dimensions when looking in your media library? Now you know how to display them by adding new columns with a little bit of code.

If you have any question, please leave it in the comments. And if you want to give me a suggestion for future snippets, please send it through the contact form.

Benefits of being a subscriber. 🙂

Admin area PHP WordPress

To leave read and make questions about this code, you can login or register.

  • About OsomCode
  • FAQ
  • Contact

Legal Notice · Privacy Policy · Cookie Policy · Terms and conditions
Copyright © 2026

close-icon

Lost your password?