donglv5269 2017-05-19 22:00
浏览 45

服务器中的图像未出现在WordPress媒体库中

I was messing around with some SQL queries and I screwed something up; and since then, images that exist on the server of the website do not appear in the WordPress Media Library. It appears to be an issue with the wp_posts and wp_postmeta tables.

I think I got the database corrupted; although, when the images are accessed through http://example.com/wp-content/uploads/YEAR/MONTH/FILE_NAME, the images are displayed and they also display fine on the homepage, but they are missing in the WordPress Media Library. Only newly uploaded images show up. I need to fix this quickly.

Any help would be appreciated a whole lot. Thanks.

  • 写回答

1条回答 默认 最新

  • dongyang1518 2017-05-19 22:13
    关注

    Items in the media library are represented by rows in wp_posts. They have post_type = 'attachment'. Did you DELETE some of those rows?

    Edit: For an item to appear in WordPress's media library, it must both appear someplace in the /uploads/YYYY/MM/ folder and in an 'attachment' row in the wp_posts table. Each media library item has its own row in that table. It seems unlikely that changing post_type values in that table will restore your media library. Unless they're still there and you somehow changed their post_type values when you were messing around. Unlikely.

    Do you have a backup of your database? If so, restore it. That is your best bet.

    At any rate, make a backup before you start trying to repair this problem. Then make regular backups. It's not hard, and it will save you untold grief in the future.

    Do you have dozens of missing items? If so, download them from your WordPress file system with FTP, then re-upload them with the WordPress media library functionality, to re-create them.

    Edit Don't delete them from your uploads/YYYY/MM folders; just re-upload them. They'll end up in two places in those folders, with the newer of the two corresponding to the newly created 'attachment' row in wp_posts. Older posts should still render correctly, using the older image files in the folders.

    If having some images show up twice in uploads is a problem, sorry. Please see my question above about backups. Don't experiment with a running WordPress instance by messing with the database. In the same way, don't experiment with your car by trying different substances in the fuel tank. If you put vodka or vegetable oil in there, the car won't run any more, and the reasons will be messy.

    Or, try using the AddFromServer plugin to restore your missing items. https://wordpress.org/plugins/add-from-server/

    Do you have hundreds, or more, of missing items? If so, you could be in a genuinely unpleasant situation.

    评论

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题