The scourge of WP image selfies

Every time I insert an image into a page or post, WP by default links the image to its file. For example, the image below links to

wp image selfies
This can be desirable in some use cases, but much more often just creates confusion. A user mouses over an image, sees that it links to somewhere, clicks on it, and is rewarded by … the image. On a page all by itself. The user then has to click back to my site or, more likely, just moves on never to return.

An obvious solution to WP image selfies is to turn off the link as I create each post or page, but new WP users will not know that. Just as I didn’t know it when I created my first, and by far my largest WP site. The site includes thousands of images, most of which ended up self-linking.

There are solutions that turn off default image self-linking going forward, but what about existing images? There seemed to be no solution other than many hours of manual drudgery, removing the link from each image by hand.

I searched Google in desperation. I got lucky and stumbled onto a brilliant, terrifying script by Michael at The script promises to remove all existing image self-links, or to destroy my site. Could go either way. Michael strongly cautions to back up the WP database before running the script. I did more than that. I made a full site backup plus two separate database backups. Then I added the code to the end of my theme’s functions.php file, uncommented the action line, held my breath, and ran a site crawler to encourage functions.php to execute.

For me, Michael’s script worked perfectly. No more WP image selfies. If you go this route, be sure to follow Michael’s advice to first backup your WP database. There is no other ‘undo’, and you never know when something could go horribly wrong. Also, I have to remember to remove the code from functions.php once it has done its job. Otherwise it will continue to run, putting a drain on my CPU.

WPPOV supports freedom from Net Neutrality and the GDPR. The Internet of the people, by the people, for the people, shall not perish from the Earth.