WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Media, directory change, paths, and database (13 posts)

  1. epicdiyom
    Member
    Posted 2 years ago #

    I recently moved a WordPress installation to a new directory on a shared host, and everything seemed to be working fine until I noticed that most of the media library images aren't working correctly.

    The images themselves are still on the server, in the correct places. The URL paths to the images work fine. But the media library displays the crystal/default.png file for nearly all image thumbnails, and those thumbnail images themselves no longer show up in the index page post excerpts like they used to.

    In short, the images are on the server, but some part of WordPress is unable to tell that they're there.

    The problem specifically seems to lie with images that were saved to the server by the "Auto Featured Image" plugin, which created thumbnails from externally hosted images that it found within the post content. Images that had been uploaded manually to the media library are still working correctly.

    This makes me think that somewhere in the database is an incorrect absolute path setting, given that the URLs work fine, but I have so far been unable to find an incorrect path setting in the database. Can anybody tell me every place in the database that WordPress might store a legacy path setting for media content, so I can update them manually if necessary?

    I've searched the forums extensively for anybody with a similar problem and haven't found a solution yet.

  2. s_ha_dum
    Member
    Posted 2 years ago #

    This makes me think that somewhere in the database is an incorrect absolute path setting.

    If you moved things to a new directory, there are probably a lot of paths in the DB that are wrong. Probably if you were to "View source" on some of those pages you could find references to the old path.

    Try using a plugin called Velvet Blues Update URLs. I've used it about a dozen times now without an issue.

    Make sure you have a backup database first. :)

  3. epicdiyom
    Member
    Posted 2 years ago #

    I'll check out that plugin, but I should point out again that the URLs are all correct. Any URL specified for an image from within the media library will lead to that image. It's just that WordPress itself doesn't see the image or display thumbnails for it. That's what makes me think there's a discrepancy between absolute paths (incorrect?) and URLs (definitely already correct).

    Is there a plugin that will allow me to update all absolute paths?

  4. s_ha_dum
    Member
    Posted 2 years ago #

    Any URL specified for an image from within the media library will lead to that image.

    I'm not quite sure what you mean. Sure, if you hand craft an URL to the image it will work, but do the URLs that WordPress generates for them work?

    That's what makes me think there's a discrepancy between absolute paths (incorrect?) and URLs (definitely already correct).

    Well, you have file system paths which can be either absolute or relative, and you have URLs which can be either absolute or relative. I think what you mean is "absolute file system path" and there are some of those in the DB.

    Is there a plugin that will allow me to update all absolute paths?

    I suppose I have never specifically checked for whether it updates those file system paths but when I've used it to move sites it seemed to correct all of the image problems.

    And you are dealing with a plugin, which adds some complexity and uncertainty to the mix.

    Just make sure you have a backup so you can back up and try again.

  5. epicdiyom
    Member
    Posted 2 years ago #

    I don't mean handcrafting a URL, I mean that the URL reported by the WordPress Media Library is correct. If I click on one of the affected images and go to the "Edit Media" page for that particular image, at the bottom of the page is a field called "File URL." The URL reported in that field is correct. The image is actually at that URL. If I copy it and paste it into the browser's URL bar, the image pulls up without a problem.

    But WordPress itself doesn't see or display the image within the media library, despite knowing its correct URL.

  6. epicdiyom
    Member
    Posted 2 years ago #

    Velvet Blues Update, by the way, found no URLs to update. They're all already correct. It doesn't seem to have an option for absolute server paths.

  7. epicdiyom
    Member
    Posted 2 years ago #

    It seems to be a disconnect between the URL and the attachment_id database entry.

    For example, on this page:

    http://www.vintagefarmfurniture.com/wp-admin/media.php?attachment_id=1474&action=edit

    The "File URL" field reports this URL:

    http://www.vintagefarmfurniture.com/wp-content/uploads/2012/06/IMG_94441.jpg

    There's an image there, but the media library won't display it. The crystal/default.png that's displayed instead of the thumbnail of that image links to this address:

    http://www.vintagefarmfurniture.com/?attachment_id=1474

    Which pulls up basically a 404 error page.

    So, what might cause a dysfunction between the image URL and the attachment_id field?

  8. epicdiyom
    Member
    Posted 2 years ago #

    Here's the meta_value field for that image in the database, in case this helps diagnose the problem:

    a:6:{s:5:"width";s:3:"426";s:6:"height";s:3:"640";s:14:"hwstring_small";s:22:"height='96' width='63'";s:4:"file";s:21:"2012/06/IMG_94441.jpg";s:5:"sizes";a:4:{s:9:"thumbnail";a:3:{s:4:"file";s:21:"IMG_94441-150x150.jpg";s:5:"width";s:3:"150";s:6:"height";s:3:"150";}s:6:"medium";a:3:{s:4:"file";s:21:"IMG_94441-199x300.jpg";s:5:"width";s:3:"199";s:6:"height";s:3:"300";}s:14:"mini-thumbnail";a:3:{s:4:"file";s:19:"IMG_94441-75x75.jpg";s:5:"width";s:2:"75";s:6:"height";s:2:"75";}s:15:"small-thumbnail";a:3:{s:4:"file";s:21:"IMG_94441-110x110.jpg";s:5:"width";s:3:"110";s:6:"height";s:3:"110";}}s:10:"image_meta";a:10:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";}}

  9. epicdiyom
    Member
    Posted 2 years ago #

    Found this page, which seemed to describe a similar problem, but his solution did not work for me:

    http://wordpressapi.com/2010/12/15/media-library-not-displaying-images-after-importing-posts/

  10. s_ha_dum
    Member
    Posted 2 years ago #

    What is the meta_key? "_wp_attachment_metadata"? If it is, then those don't match what I am seeing locally. The part after "file" should be an absolute system file path starting at root-- something like "/var/www/vhost/websitename/httpdocs/wp-content/uploads/2012/06/IMG_9441.jpg"

  11. epicdiyom
    Member
    Posted 2 years ago #

    Yes, meta_key for that record is _wp_attachment_metadata.

    Are you saying it should be an absolute path after every instance of "file"? Some instances designate a relative path, and others only a file name.

    It's worth noting, though, that the meta_value field for images that are currently working correctly on the site have this same structure -- relative path and file name, but no absolute path. If that's the problem, why would some images with that type of meta_value work and others not?

  12. epicdiyom
    Member
    Posted 2 years ago #

    This seems applicable to my problem, because the affected Media Library images were created with the Auto Featured Image plugin:

    http://wordpress.org/support/topic/plugin-auto-featured-image-thumbnails-not-showing-after-upgrade-to-34?replies=7

    I'll see whether their solution works...

  13. epicdiyom
    Member
    Posted 2 years ago #

    SOLVED:

    OK, this did indeed fix the problem:

    http://wordpress.org/support/topic/plugin-auto-featured-image-thumbnails-not-showing-after-upgrade-to-34?replies=7

    I had to delete nearly 700 images manually from the Media Library, then add a line of PHP code to the Auto Featured Images plugin, and regenerate the several hundred automatic featured images that had stopped working.

    So, the cause of the problem was upgrading WordPress. I guess it was just a coincidence that this problem roughly coincided with changing the WordPress installation directory.

    I never would have expected that a simple upgrade from WordPress 3.3.2 to WordPress 3.4 could destroy 98% of my Media Library. Live and learn.

    Thanks again for your help, s_ha_dum!

Topic Closed

This topic has been closed to new replies.

About this Topic