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. I personally faced this issue and that time I got very frustrated.
I did spend one hour googled for solving the issue but I did not found 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.
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%'
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 quries.
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.