Recently, one of our clients was having trouble with their WordPress site: when trying to add media from the Media Library to a post or page in Chrome on Windows, the browser tab would simply crash immediately upon attempting to load the media library. Basically the Media Library lightbox would open, then either right away as the image thumbnails started to load, or sometimes after about half of the thumbnails had loaded, the browser tab would crash completely. (The same problem materalized when trying to load the Media Library page in the backend of the site as well.)
Since I had no luck finding a solution by Googling this problem, I wanted to share my findings.
The problem, as it turns out, was that several large images that had been uploaded to the site the previous week were bogging down the media library, causing the browser tab to crash. These images were all over 4MB, and upon removing them from the server, the browser no longer crashed.
My solution was to optimize the images for or client and put them back on the server at a greatly reduced file size and put a limit of 4MB on the file size for future uploads, in order to prevent this from happening again.
Limiting File Upload Size in WordPress
I found lots of information and different techniques on how to limit the file upload size in WordPress, but unfortunately most of them either didn’t work at all, or failed to change the message on the upload screen that notifies the user of what the maximum file upload size is. For example, even though the file upload size was being effectively limited to 4MB, the message below the file upload input still said “Maximum upload file size: 8MB.” which isn’t very user friendly.
Here’s how I got it to work and update the maximum file size message – place the following line of code in your .htaccess file.
php_value upload_max_filesize 4M