Getting blank thumbnails in media library?

I had a very similar problem, on a multisite with 8 blogs (2 of them).

In my case I discovered that the the meta_value “_wp_attachment_metadata” of some images were corrupted in the table wp_xx_postmeta. It probably happened due to some plugin, because the last thing I did before this issue was to remove several unused plugins. But reinstalling them didn’t solve it…

In a short, I recovered the meta_value(s) from an old database backup
that had the correct values.

Here is what I did:

0 – First of all, I imported the SQL file of the OLD database into a separate database, in order to use both databases in the MySQL server at the same time.

1 – Selected the IDs of all attachments in wp_xx_posts from the old database

SELECT * FROM wp_xx_posts where post_type="attachment";

where “xx” is the number of the blog with problem.

2 – Selected all meta_id and meta_value in wp_xx_postmeta for the attachments from the old database:

Select meta_id, meta_value from wp_xx_postmeta where meta_key = '_wp_attachment_metadata' and (post_id = 111 or post_id = ...);

For all image IDs. By copying/ pasting/ replacing the data between an Excel spreadsheet and the notepad it’s easy to create the query for all IDs.

3 – Created a SQL file with the updates of wp_xx_postmeta to be imported to the CURRENT database. This file might be a little bit large, and each line would be something like:

UPDATE wp_xx_postmeta set meta_value="a:5:...a large serialized bunch of data" WHERE meta_id = 111;
UPDATE wp_xx_postmeta set ...

For all images. Again using Excel/ notepad.

4 – Then I executed the SQL file using mysql -u root -p current_database < sqlfile.sql

When I reloaded the site, all thumbnails and all images were working properly on the media library.