I finally found the solution to this problem which as turns out plagues many wordpress installations. Right after uploading an image through the "add media" button in an editor, the upload would fail with a "an error occurred in the upload error". However after refreshing the image would appear in the media browser window but when inserted into the editor it would show up with width and height both set to 1px.
After searching a lot without any success I solved the problem. Many people reported solving it by disabling all plugins one by one to find which was causing the problem. In my case it was a fresh wordpress installation without anything else, not even custom themes. So I decided to post it here in case anyone else is search and stumbles upon this post.
My problem was with the
functions.php
file. The thread here helped me solve the problem.I found a simple solution. If you save the post you are working on as a draft, then attempt the upload again, it works. This appears to happen if you have been drafting a document for a long time, without manually saving. Once you manually save, it resets the upload ability somehow, and the problem goes away.
Sometimes this problem comes with uploading/restoring the db-backup from file via phpmyadmin. The import can skip adding
auto_increment
towp_posts
andwp_postmeta
tables at0
key.This leads to crash in the further work of the site and eventually you wan't be able to add new posts/pages ("you are currently editing the page that shows your latest posts" instead of the text editor), upload new images (you'll see the empty window where once was all your image gallery).
The issue can be easily fixed by deselecting the checkbox near the "Do not use AUTO_INCREMENT for zero values" when importing DB through
import
section of phpmyadmin. However, it still can be imported with errors and you'll need to addauto_increment
towp_posts
andwp_postmeta
tables manually after the import complete.Turns out the culprit was imagemagick. I disabled it in php.ini and everything started working again. If your host supports it you can use a custom php.ini file.
I too had this issue with a plugin I wrote. Root cause seems to be a WordPress interference with the javascript call
window.requestAnimFrame
. Info provided here for anybody else searching on the error message.The plugin I wrote was a simple little thing to post a fixed box on the top of the screen that showed browser window size. The plugin would update four times / second using
window.requestAnimFrame
calls. I'm guessing something in the routine that updated the media upload progress bar interferes with the call. And I was all set to publish that plugin too, sigh.Not sure of the exact details on why this makes WordPress media uploads fail, but its yet another root cause. Note: the media files did actually upload, but the feedback system just errors out on the admin end. Note: not sure I was supposed to, but I submitted a bug report to core WordPress.
In my case, I had moved moved wordpress to a new server and was getting this error. It turned out that I hadn't installed imagemagick on the new server.
and then a restart of the web server solved the problem.