After setting up a new WordPress site, I realised that TimThumb (a popular open-source thumbnail generation script) wasn’t working and was returning a 404 error page.
Let’s assume that you have TimThumb installed here:
http://www.yourdomain.com/wp-content/themes/yourtheme/timthumb.php
Let’s also assume that your image (that you want a thumbnail of), is located here:
http://www.yourdomain.com/wp-content/uploads/images/image1.jpg
This means that your full TimThumb url for the thumbnail will be:
http://www.yourdomain.com/wp-content/themes/yourtheme/timthumb.php?src=http://www.yourdomain.com/wp-content/uploads/images/image1.jpg&w=300&zc=1&q=80&bid=1
First of all, make sure that the following are true:
- Accessing the TimThumb file directly (at http://www.yourdomain.com/wp-content/themes/yourtheme/timthumb.php) works and shows you a “A TimThumb error has occured” page stating a “No image specified” error message. This shows you that the script is working fine on it’s own.
- Your images can be accessed directly, meaning this URL works: http://www.yourdomain.com/wp-content/uploads/images/image1.jpg.
If so, you’re most likely suffering from the same issue that I faced, and just need to either fix the permissions of your files/folders, or disable any security plugins that you have running. To change permissions, right-click on the files/folders using your FTP client or CPanel file manager and select “Properties” or “Change Permissions”.
First, set the permissions of the following directories to 755:
- wp-content
- wp-content/themes
- wp-content/themes/yourtheme
- wp-content/themes/yourtheme/cache
Next, set the permissions of the TimThumb file to 644:
- wp-content/themes/yourtheme/timthumb.php
And that’s it – you should fix the problem of your TimThumb.php file giving you 404 errors now.
WordPress