Disappearing Images Fix
-
Hey All, I have had two separate sites where the images on posts and pages disappeared. They were there one day and then we made edits to a post/page and they were gone. Not all images, just some of them. What happened is that the post_type value for a media item was changed from attachment to page. I still don’t know why this happened. It could have been an issue resulting from the recent Yoast SEO fix, or maybe the change post type plugin, or something with Advanced Custom Fields since it was those fields that were losing their images. In any case, my fix for those was to run the below query. Hopefully this is able to help someone else. The gist of the query is that it looks for all posts that have a post_mime_type set. If it does, and it’s not set to an attachment post_type, then it makes the switch.
update wp_posts set post_type = ‘attachment’ where post_mime_type like ‘image/%’ and post_type <> ‘attachment’;
- The topic ‘Disappearing Images Fix’ is closed to new replies.