Support » Fixing WordPress » Media library partially broken

  • Hi everyone!

    I’ve been running a WordPress installation for some time now on my own virtual LAMP server and so far everything worked fine. But since the server crashed violently recently, I’m encountering a strange problem: In media library in the admin backend, for most images (mostly JPEG, some PNG) no thumbnails are shown but only a standard grey icon. For a few images however, proper thumbnails are still shown.
    This effect has so far also “survived” at least to automatic updates of WordPress.

    At first, I checked the access rights of the image files in the file system and they look OK. Also the image files which show the icon problem in the media library are shown just fine when directly in the browser with a deeplink.
    In an attempt to further troubleshoot this, I’ve doug my way through the WordPress code down to WP_Object_Cache::get() in /wp-includes/cache.php. When called in the context of a “good” image file, it returns an array with two elements “_wp_attached_file” and “_wp_attachment_metadata” with the first of which containing the path to the image file. But when called in the context of a “bad” image file (i.e. an image that is shown with a default icon in the media library), it just returns an empty array.

    This was the point where I couldn’t get any further. How exactly is WordPress’ caching mechanism filled with data?
    Or, going back to the original problem: Has anyone experienced this so far? What could be a solution to this problem?

    Best regards
    sjs77

Viewing 9 replies - 1 through 9 (of 9 total)
  • Have you tried clearing your server side cache?

    Thread Starter sjs77

    (@sjs77)

    How can I accomplish this?
    (I’ve already googled for clearing WP’s caches, but so far no instructions found did match my installation – mainly, because I don’t use any WP cache plugins.)

    Best regards
    sjs77

    First you need to check to see if you can find define('WP_CACHE', true); anywhere in your wp-config.php file. If you do then disable it by changing true to false. If you don’t see it then check to be sure you are not using a caching plugin and if you are simply disable the plugin.

    If neither of the above fixes are possible then you need to check your theme to see if it has any caching features included within it. After that, it would see there is either a misconfiguration of your virtual LAMP stack or a plugin conflict that is causing the error you are getting.

    I hope something out of what I just said helps you to determine the issue.

    Thread Starter sjs77

    (@sjs77)

    • WP_CACHE wasn’t set in wp-config.php, so I added a line, setting it to false.
    • I just doublechecked: no, there are no caching plugins installed.
    • The theme I’m currently using is “Responsive Mobile”. For testing purposes, I changed to “Twenty Sixteen” with no effect.
    • I’ve just set up a new, parallel installation of WP out of the box on the same virtual machine and within that, the media library seems to work perfectly fine. So I don’t think that the issue is with the system itself.

    So, summing it up, unfortunately, none of the tips so far had any effect on the problem at hand. 🙁

    Best regards
    sjs77

    There must be some malignant code or something causing this in the theme orna plugin on your first install. I’m not familiar with that theme unfortunately… and I’m also out of ideas as to what it could be.

    my only other suggestion would be to import all content from the first install into the new one using the built in export/import tools and see if they cache errors return. if they don’t proceed with the new install… if they do they there’s some code somewhere in your setup causing this.

    sorry I’m not able to help any further. I’m going to ping the other active members and ask them to take a look at the thread. maybe someone else has other ideas.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    I have a client a where the db crashed often, resulting in one or more corrupted tables. Repairing those tables via phpmyadmin is the fix. I since changed the tables from myISAM to InnoDB and the crashes have stopped. In this client’s case, the tables were wp_posts and wp_postmeta.

    Check all of the tables and, if necessary, repair them.

    https://www.a2hosting.com/kb/cpanel/cpanel-database-features/optimizing-and-repairing-mysql-databases-with-phpmyadmin

    https://www.siteground.com/kb/how_to_change_the_database_engine_of_a_mysql_database_table/

    Thread Starter sjs77

    (@sjs77)

    I just played around with the again and finally seem to have identified the root cause: The system crash mentioned earlier must have affected the corresponding MySQL database – for all “broken” images, the corresponding entries in the “postmeta” database table are missing.
    But of course manually adding these datasets for a couple of dozens (hundreds?) images would be a bit tedious (not mentioning that I haven’t fully understood the content of “_wp_attachment_metadata” value)… Is there any tool or plugin or whatever that scans the “post” table and recreates missing entries for images in the “postmeta” database table?

    Best regards
    sjs77

    Thread Starter sjs77

    (@sjs77)

    @steve: You sent your post just before I finished mine. 🙂
    Yes, indeed, it also seems to be database issue with my installation. But in my case, the database tables already show up again as “OK” in phpMyAdmin, so I’m afraid that the data mentioned above is lost for good. 🙁
    So, is there solution to automatically reconstruct the missing metadata based on the post data an the actual image files on disk?

    Best regards
    sjs77

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    You might try rebuilding the thumbnails on your site.

    If you have wp-cli installed, it’s the fastest way: https://developer.wordpress.org/cli/commands/media/regenerate/

    Or use this plugin:
    https://wordpress.org/plugins/regenerate-thumbnails/

    Either will regenerate the derivative images for the images already in the library and update the metadata

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Media library partially broken’ is closed to new replies.