As the title says, I want to automatically remove a specific image in all posts where it's used when I remove the image from the media library. Because at the moment, if I remove an image from the media library the "empty image" stays in the post(so all the html code) but nothing is being displayed of course. Is there any way/plugin?

Thanks in advance.


I was not able to find plugin for that and I think there might be a problem to find one.

Problem is not easy to solve because as I just checked in WordPress database reference (http://codex.wordpress.org/images/9/9e/WP3.0-ERD.png) there is not special container for images in post content.

If I understand correct your plugin needs to:

  • hook to action when media is removed,
  • search through all your posts looking for image url,
  • find in post content image url and html 'a' tag for it,
  • remove 'a' tag with image tag

It is not soo hard to write it but performence of plugin depends on how many posts you have on your blog.

  • That's what I thought, I'll have to do it the hard way with regex :) I'll have to code it tomorrow then and post my results here. If anybody got any other suggestions that would be great. – Stephan S. Dec 17 '12 at 23:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.