Add GPS Coordinates Column to Images in WordPress Media Library

Cleanshot 2025 05 31 at 09.27.42@2x optimised.png

Ever find yourself staring at a bunch of photos in your media library wondering “Where the heck was this taken?” If your images have GPS data embedded in them, this little snippet will save you from playing detective. No more opening each image individually or digging through EXIF data manually.

What it does…

This snippet adds a sleek new “GPS” column to your WordPress media library that automatically pulls location data from any images that have GPS coordinates embedded in their EXIF data. When you upload photos from your phone or camera that has location services enabled, you’ll instantly see the exact coordinates where each photo was taken. The coordinates appear as clickable map links that open Google Maps in a new tab, plus there’s a convenient copy button that lets you grab the coordinates with a single click. It works seamlessly with your existing media library without requiring any database changes or complicated setup. The column even disappears on mobile screens to keep your interface clean and responsive.

Why it does it…

Most cameras and smartphones automatically embed GPS coordinates into image files when location services are enabled, but WordPress doesn’t expose this valuable metadata in the admin interface by default. This creates a frustrating gap where you have location data sitting right there in your files, but no easy way to access it without third-party tools or manual EXIF inspection. The snippet bridges this gap by leveraging WordPress’s built-in wp_read_image_metadata() function, which was specifically designed to extract metadata from images but rarely gets used for GPS data in most themes and plugins. Rather than requiring external APIs or complex database modifications, this approach taps into existing WordPress core functionality and falls back to PHP’s native EXIF functions when needed. The implementation prioritizes reliability and performance by using multiple extraction methods and caching the results, ensuring you get accurate coordinates without slowing down your media library.

How it does it…

  • Hooks into WordPress media columns using the manage_media_columns filter to add a new “GPS” column that appears just before the date column in your media library table
  • Extracts coordinates through multiple methods starting with WordPress core’s wp_read_image_metadata() function, then falling back to PHP’s exif_read_data() if the primary method fails
  • Parses GPS EXIF data by converting the complex fractional degree format (like “40/1, 45/1, 30/1”) into decimal coordinates using custom gps_to_decimal() and fraction_to_float() methods
  • Renders interactive coordinate display with HTML that includes the decimal coordinates, a clickable Google Maps emoji link, and a clipboard copy button with visual feedback
  • Implements JavaScript copy functionality using the modern Clipboard API with a legacy fallback that creates a temporary textarea element for older browsers
  • Handles dynamic content updates through a MutationObserver that re-initializes copy buttons when the media list gets updated via AJAX
  • Provides responsive design with CSS that hides the GPS column on mobile screens and styles the coordinate display for optimal readability

See the code on github…