Last Updated: February 25, 2016
·
715
· 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:

https://github.com/magnetikonline/wordpressvalidatepostimgurl

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 :)

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.

Security insights from Cside