WordPress 2.5 Broken Media Library Fix

The Media Library in WordPress 2.5 is a great new feature. Unfortunately, it doesn’t work for many users right out of the box.

Tags: infrastructure wordpress

Server Configuration (IIS)

If you are running your blog on IIS, and you are unable to upload files, make sure that your PHP configuration file is set up correctly and that your web server has access to PHP upload directory.

The php.ini should contain the following entries:

  • file_uploads = On
  • upload_tmp_dir = "C:\Example\Upload\Folder"

Obviously, you can set an upload directory of your choice. Make sure that the IIS_IUSRS user account has full access to this directory.

Server Configuration (Apache)

If you are running WordPress on an Apache web server, you might not be able to upload files to the media library with following symptoms:

HTTP Error
An error occurred in the upload. Please try again later.

To fix this issue, add the following lines to the end of your .htaccess file in the root of your WordPress installation:

<IfModule mod_security.c>
   <Files async-upload.php>
       SecFilterEngine Off
       SecFilterScanPOST Off

JavaScript Fix

The release version of WordPress 2.5 has two typos in the source code that cause the Media Library to break with the following symptoms:

  • Files can be uploaded but not actually added to postings.
  • The Show links in the media library don’t work
  • The browser shows an Object Expected JavaScript error at line 136

To fix this issue, you have to manually edit two files of your WordPress installation in a text editor:

  1. Open the file wp-admin/includes/media.php
  2. At line 817:
    debug: false,

    remove the comma after false:

    debug: false

    and save the file

  3. Open the file wp-includes/js/swfupload/handlers.js
  4. At line 99:
    .animate({minHeight:0,height:36,}, 400, null …)

    remove the comma after 36:

    .animate({minHeight:0,height:36}, 400, null …)

    and save the file.

Related Resources

The server configuration fix was posted on many forums and blogs. The JavaScript bug fix was first posted on the WordPress Trac bug tracker.