Fix for When a WordPress Blog Stops Displaying Images

My WordPress network site stopped displaying uploaded images. I finally found something that works, though it is a lame “solution” in my opinion.

I found this advice and it worked for me. Insert the following in wp-includes/ms-files.php

adding ob_clean() before the readfile in ms-files.php

So you end up with:

[bash]// If we made it this far, just serve the file
readfile( $file );

Caching seemed to make the images “disappear” slowly (they didn’t all go at once and using different browsers they “disappeared” at different times). So when I fixed it they “reappeared” at different times (it seemed like cached ones stayed disappeared for awhile).

The advice mentions the image files being seen as “corrupted.” The files seem unlikely to actually be “corrupt” because these are images that worked for years and then all of a sudden every image for the sites “disappeared” (wouldn’t be displayed). I suppose it is possible the are corrupt in some detailed way and some update no longer allowed some previous “lax” checking to allow the non-compliant files but it seems more likely that some of thing has gone wrong (but somehow ob_clean takes care of it).

Related: WordPress error: Image could not be processed. Please go back and try again.Overcoming Conflicts Multiple Blog WordPress Network on One ServerBash Profile Adjustments, Scrolling History

3 thoughts on “Fix for When a WordPress Blog Stops Displaying Images

  1. If the images will display properly using the direct url (based on the file structure on your server) but fail to show up in posts you should look at your .htaccess file. WordPress rewrites the directories for the web instead of just using the ones on your server so if the WordPress created public url fails but the link using the server files works it means there is some problem in creating the WordPress url for the photos.

    Such a problem should mess up all the photos but it may be temporarily only failing to display some photos because some are cached.

    The code needed in .htaccess should be created when setting up the WordPress multisite blog but if that modification is overwritten at some point, the current code to fix this is adding this to the .htaccess file:

    RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]

    I would suggest checking the WordPress support site to see if there is an update to the .htaccess code for blog networks.

  2. Pingback: Compare WordPress Files on Server to Proper WordPress Version | Coding and Server Syntax Examples

  3. Pingback: Fixing a Problem with WordPress Trackbacks and Pingbacks | Curious Cat Coding

Comments are closed.