Media Library not displaying images after importing posts

Media Library not displaying images after importing posts

Earlier I have blog in wordpressmu  then after wordpress 3.0 version I decided to migrate to new version. I exported my all posts by using the wordpress  export tool. Then I imported data into new wordpress installation. I got all my posts and category and all the data. Then I checked all my attachments.

Then I saw my media library I saw all the images listing are there but images are not showing in media library. Media Library not displaying images after importing posts. I personally faced issue and got frustrated. then I solved issue myself using mysql query trick.

Media Library not displaying images after importing posts

Media Library not displaying images after importing posts
Media Library not displaying images after importing posts

When I checked my database I saw the all the my attachments are listed in post table but images are not displaying. All the places I only saw the wp-includes/images/crystal/default.png image.

I did spend one hour googled for solving the issue but I did not find any solution for this. Than again I checked my Folder permissions and images files but I found all things are perfect.
Then I checked my database and I found the issue. in wp_posts table ->post_mime_type column one entry was missing. After seeing that issue I fixed the issue.

I used the following mysql quires using myphpadmin tool.

[viral-lock message=”Solution code is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]

Update wp_posts set post_mime_type='image/jpg' WHERE guid like '%jpg%'
Update wp_posts set post_mime_type='image/jepg' WHERE guid like '%jepg%'
Update wp_posts set post_mime_type='image/png' WHERE guid like '%png%'
Update wp_posts set post_mime_type='image/gif' WHERE guid like '%gif%'

[/viral-lock]

After using above query I checked the my media library. I am able to see my all images in media library.

My advise to you is first take backup of your database and then use above mysql quires. Then use the above queries.

If you are imported post from other website then use following commands also.


UPDATE wp_posts SET post_content = REPLACE(post_content, 'NEW-DOMAIN-NAME', 'files/');

UPDATE wp_posts SET post_excerpt = REPLACE(post_excerpt, 'NEW-DOMAIN-NAME', 'OLD-DOMAIN-NAME');

UPDATE wp_posts SET guid = REPLACE(guid, 'NEW-DOMAIN-NAME', 'OLD-DOMAIN-NAME');

Above quires will change the domain location of file.

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

5 thoughts on “Media Library not displaying images after importing posts”

  1. this function was normally worked about 1 year.

    now when I try to upload new image on my post,image uploading normally, but on wordpress it’s not visible,please share your experiance.

  2. The same problem appeared at my WordPress Media Library, I couldn’t see the images in the library (only wp-includes/images/crystal/default.png image) but the pictures do exist in the right folder and they are displayed in the posts as well.

    This happened after the upgrade to WP 3.5.1. If I upload new pictures, it’s no problem, it only happens to the images I uploaded before the upgrade.

    If I check the database, the post-mime-type for all images is: images/jpg . So your solution seems great but it’s not working for me… Any other suggestions? Thanks!

  3. Very bad post, Everything is wrong … Do not make this !!!

    The good way :

    UPDATE wp_posts SET post_excerpt = REPLACE(post_excerpt, ‘OLD-DOMAIN-NAME’, ‘NEW-DOMAIN-NAME’);

    UPDATE wp_posts SET guid = REPLACE(guid, ‘OLD-DOMAIN-NAME’, ‘NEW-DOMAIN-NAME’);

Leave a Reply to Fabien Cancel reply

Your email address will not be published.