PHP snippet · Media & Files

Media library file size and dimension columns

Adds Dimensions and File size columns to the media library list, so the 4 MB hero image is visible without opening anything.

About this php snippet

The media library list gives you a thumbnail, a name, and a date, but not the two things you actually need when you are hunting for whatever is making a page heavy. Today, finding the 4 MB hero somebody uploaded straight off a camera means opening attachments one at a time.

Two columns, no settings, and the answer is on screen.

What it does

  • Adds a Dimensions column showing the width and height of each image
  • Adds a File size column, formatted so it reads at a glance
  • Sits alongside the existing columns with nothing to configure

Good to know

  • File size is read from the attachment metadata where WordPress recorded it, and falls back to measuring the file on disk for older uploads that predate that field, so the column is not blank on a library that has been going for years
  • Anything without dimensions, such as a PDF or an audio file, shows a dash rather than a broken value
  • These are display columns, not sortable ones. They are for scanning a page of results, not ordering the whole library.
  • This is the list view. The grid view is unchanged.
  • Pairs well with the EMCP image optimization module when you are auditing a library that has got out of hand.

More php snippets

Your EMCP guide

Answers from our docs

YOUR CHAT, YOUR CHOICE

Before we chat

MSR Builds processes your question and up to four recent messages on our server to answer from the EMCP docs. AI is optional and needs your separate permission.

The chat is kept in this page's memory, not saved as a conversation in our database or browser storage. Our hosting and security services process connection information, such as your IP address, to prevent abuse.

Cloudflare Turnstile checks your browser and connection to prevent automated abuse when you send a question. No login is required.

Please leave out personal, sensitive or confidential information, passwords and API keys.

You can withdraw consent and clear this page's chat at any time. This cannot undo a request already sent or erase provider/security records.

Chat privacy, retention & your rights ↗ · Privacy contact

Starting chat consents to this processing. You can browse our docs without using the chat.