TimThumb is a script commonly used for image cropping and resizing in a lot of WordPress themes. It’s good at what it does but it also has a few drawbacks.
The majority of image-related problems I’ve encountered on WordPress websites have been due to TimThumb, but normally these are quite easy to fix – incorrect cache permissions, plugin conflicts, misconfigured options and the like.
Recently I ran into a new issue that left me scratching my head. TimThumb was giving the following error:
A TimThumb error has occured
The following error(s) occured:
Could not get a lock for writing.
But none of the usual culprits was to blame.
The website was on a shared Linux host using the typical settings recommended for WordPress, and I noticed that there were two versions of PHP available on the server, the default 5.2 and the latest 5.3, which was activated for this particular site.
I decided to revert to the default version of PHP by removing the line below from the .htaccess file.
AddType x-httpd-php53 .php
Surprisingly, this worked and the ‘write lock’ issue disappeared immediately.
I’m not yet certain what part of the change in PHP version would have this impact on TimThumb, but definitely something worth remembering for the next time!