Attachment metadata randomly missing

by That Brazilian Guy   Last Updated February 28, 2019 17:08 PM

I have this website with about 3000 posts and 4000 images in the media library.

For a long time now, some image thumbnails will randomly disappear from the media library:

enter image description here

When I click to open the attachment details, I can see some of its details, like the upload date, size, URL, title, caption, etc.

enter image description here

Clicking the "Regenerate Thumbnails" button produces an error message stating "ERROR: Unable to load the metadata for this attachment".

enter image description here

If I copy the URL and paste it on the address bar, I can see the image.

It is also displayed correctly as the featured image on the post edit metabox.

Examining the database, I noticed these images with broken thumbnails are missing its _wp_attachment_metadata metadata entries from the wp_postmeta table.

According to the content creators, when the posts are created and the images are uploaded they display fine, and after a period of time they start disappearing randomly. I haven't been able to detect a pattern.

We're running WordPress 5.1 with Apache and PHP 5.6, but these issues happened before on different versions and also back when the site was hosted on a different environment, running nginx with a different PHP version.

Related Questions

Programmatically adding images to media library

Updated February 17, 2017 12:08 PM

Regenerate missing _wp_attachment_metadata

Updated February 27, 2019 20:08 PM

Get post embedded image caption

Updated March 24, 2016 08:03 AM