Last Updated: February 25, 2016
· magnetikonline

Hunt down broken image URLs within WordPress blog posts

Recently had a need to verify that all internal image references used within the posts of a WordPress blog did in fact link up to a valid image within the wp-content/uploads/ directory.

There were a few thousand posts to validate so, I wrote something small (and rather a hack!) as a PHP script for the task at hand:


Designed to be run from the shell/CLI, it works over all your published blog posts, extracts image URLs and then validates the referenced image actually does exist on disk under wp-content/uploads/.

Hope it's of use to someone :)

Say Thanks