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:
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:
In the code above you use several hooks, specifically:
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.
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. 🙂