Unattaching unlinked images

wordpress sucks in keeping media<=>content relationships. Part of the problem is that by default all media are public once they are uploaded and you have no way to know where are they are being used. Just because an image is not referenced anymore in its original post doesn’t mean that it is not referenced at any other place (sidebar widget?) or maybe by some external site, therefor deleting an image just because it is unattached is a very dangerous idea that can lead to a very big fail situation.

For what you want I think it is better to use the actual server access log than the content. Get a process running that once a month goes over all the images and find those that didn’t have any hits, and go and delete them.

Leave a Comment