I often get asked questions about TimThumb and why it doesn't work in certain situations. I can generally tell what is wrong with the script within about 60 seconds of being sent a demo url. Below are my top tips for debugging TimThumb issues.
Keep TimThumb up to Date
This is super important. TimThumb should always be kept up to date. I regularly publish bug fixes and improvements and often the problems listed below will actually be fixed already if you only used the latest version. Just grab the latest version of TimThumb from Google Code and upload it. Is your problem fixed now? If so then great!
If not then read on and we'll sort it out!
If you've not heard of TimThumb before then it's a simple PHP file used to resize images dynamically. You can read more about it, and find some 'getting started' style hints and tips on the TimThumb Project Page.
TimThumb Secrets
- Right Click > View Image - If an image isn't loading then this is the first thing you should do. 9 times out of 10 it will tell you what the problem is in an easy to read error message.
- Supply an Image url - this is surprisingly common. TimThumb is clever, but unfortunately it needs to be fed image paths so that it knows what to resize. This is pretty fundamental, you can read more info on getting started with TimThumb here.
- urlencode(url-with-parameters); - if the image you are resizing is a dynamic one (ie, it has &skdh=khdkfs&ksjdsjd=ksh) then it is unlikely to resize properly. Simply change your image url so that it is wrapped in a call to the urlencode PHP function. This is something I would always recommend doing as it will encourage TimThumb to work in more situations.
- Cache Directories do not exist - For TimThumb to work properly you need to have a cache directory called cache sitting alongside the timthumb.php file.
- Cache Directory Permissions - the cache directory should exist inside the same directory as TimThumb. It should have permissions set to 777.
- More Cache Directory Permissions - if 777 doesn't work then you may find 755 is ok. It's worth a try, but not something I have seen very often.
- Cross Domain Request - for security TimThumb restricts cross domain requests. Certain websites, such as Flickr, are allowed by default, but if you want to load an image from another website then you need to make sure it's added to TimThumb. You can read about cross domain TimThumb requests on a previous post.
- File Permissions - some web hosts won't execute PHP code if it sits in directories that have permissions set to 777. So make sure that any directories 'above' the timthumb.php file are set to a normal level of permissions (644 is good).
- Use with WordPress mu/ multisite - It's a common misconception that TimThumb doesn't work with WordPress Multisite. That's not true at all. All Pro Theme Design themes use TimThumb and work fine with the multisite version of WordPress. To make it work you need to customise your theme, and there's info on this in my tutorial here.
- Server Requirements - this should go without saying really but TimThumb requires PHP and the GD image library. These are really really common so you shouldn't have any problems. If you find yourself without these installed then ask your webhost and many will install the software for you - if they don't do the installation it's probably worth considering a new host.
- Image Formats - make sure that the images are one of jpg, gif, or png or they won't be resized.
- index.html - to prevent the cache files from being browsable an index.html file is created in the cache directory. This file should have it's permissions set to 666
Hopefully with the hints and tips above you will be able to solve most common TimThumb problems. I plan to keep updating this list so if you have any other comments or suggestions just post in the comments and I will update as I go.
Que es TimThumb, y solo se usa en WP ?
Saludos y no se como llegue aquí.
December 11, 2012
Hi, I'm having problems getting thumbs to show properly on http://triathlon.no - any help appreciated.
Some images appear/disappear on refresh? I'm baffled!
Thanks in advance, and Merry Christmas!
December 17, 2012
i have the exact same problem and i didnt change anything. how did you go?
January 18, 2013
Still no solution I'm afraid.
January 19, 2013
Hi Ben, how are you? I'm really hoping you can help me.
For the last year I've been running our photography company's website on WordPress. Everything's been running great and then all of a sudden a couple weeks ago our thumbnails stopped working for no reason at all. We hadn't made any changes to the site, theme, or WP version.
Here is an example of a problem page:
http://siskphoto.ca/concert-photography/
Since the site is a photography company site, the majority of it is photos and now none of our gallery thumbnails work, this is not good at all. =( The images are still there and if you click on the broken thumb, the image still loads up.
I've done tons of research and checked everything mentions on your site too and I can't for the life of me figure out what the problem is. I've looked at the permissions so many times too.... =(
If you have any ideas what the problem might be I'd be forever grateful to you. Please help.
Thanks,
Erin Fraser
January 4, 2013
Hi - sorry to hear you are having problems. Check out my rates for TimThumb tech support and let me know if you want me to give you a quote.
January 6, 2013
Hi Ben,
Thanks for the reply.
I've made a discovery. After putting a whole new WP installation on and trying a few test photos, it seems the only photos/thumbnails that work properly are the ones who have underscores in their file name. If they have dashes in the file name the thumbnail is broken.
Have you heard of this happening before? Do you have an idea of how to fix it?
January 10, 2013
Kudos to Ben! Changing the permissions from 755 to 777 on the cache folder solved my site's problem of not loading the images! Thanks!
January 9, 2013
Hi,
I am having problems with my thmb pics on http://www.bbworld.com.au i have tried config timthumb but with no luck any ideas?
January 18, 2013
So, I have TimThumb 2.8.11 working without a problem and thanx ... it is a really nice, convenient script for what I need.
My question is in regards to the cache files ... do I have to create a script that will delete them periodically? or does TimThumb do that itself?
just curious as I do not want to have thousands of state cache files sitting around on my server
Thanx
Gordon
January 21, 2013
TimThumb automatically makes sure that the directory doesn't get out of hand
January 21, 2013
Hi there,
I recently moved http://www.footy.co.za to a new host, but for the life of me, can't get timthumb to work.
I have gone through all the permissions & setting of folders, but still having no joy. Is there something I am missing ?
Any help would be greatly appreciated !
Thanks in advance
Marc
January 21, 2013
To all other readers, do not set your `cache` folder permission to 777, set it to 755. You'll get easily hacked if you follow the permission he posted here.
January 28, 2013
Great script!
Question - Whats the best way to keep updated on the latest releases?
For example i just found out today that you went from 2.8.10 to 2.8.11 last month...
Without checking in every day I don't see a newsletter or anything that would send me notification of these changes.
Please advise.
Thanks,
Jay
January 30, 2013
The Google Code commit page has an rss feed so if you subscribe to that you can get update immediately - https://code.google.com/p/timthumb/source/list
January 30, 2013
Hey
Thanks for your work and sharing with us! I'm using Website Screenshots and spent some time searching for the reason why they're always cropped to 800 x 600 - no matter of the adjustments in WEBSHOT_SCREEN_X / WEBSHOT_SCREEN_Y
It's easy: Tell CutyCapt this resolution too!
In timthumb.php (2.8.11) add --min-width={$screenX} --min-height={$screenY} to $command at line 970 and 972 and you'll get what you want.
February 14, 2013
I have followed all steps.
But he still shows me no thumbnails. : (
Can someone help me please?
February 22, 2013
sorry i forgot a screenshot ..
All pictures are shown in the preview in full size: (
February 22, 2013
Hi Ben,
thank you for creating TimThumb!
I have the problem that with every request a new cache file ist created. When I Refresh the page a new cache file ist created (for one image) every time which results in a lot of cache files for the same image!?
For example image "test.jpg":
Request 1 -> Cache file is: ./cache/timthumb_int_46b8d758e92c92194fe777812b5e1256.timthumb.txt
Request 2 -> Cache file is: ./cache/timthumb_int_55e1665e99490a3cdf486ee69294e9ba.timthumb.txt
It seems that the earlier created cache file ist not found by the script!? Or is this normal behaviour?
Thank you in advance and best regards,
Frank
March 1, 2013
That sounds strange - I haven't heard of that before :S
March 2, 2013
i used it on my website but i found many problems, images dont appear on the website and hadn't been created on the cache folder
March 4, 2013
Hi Ben,
I have follow all the instruction, but I come up with this one:
Warning: tempnam() [function.tempnam]: SAFE MODE Restriction in effect.
Any Idea? Need Advice.
Thanks.
March 23, 2013
Hey Ben,
Wondering if the issue with the thumbnails not appearing is solved. Just shows a thing empty box there the thumbnail is supposed to be. Was working with the test images I was working with, but once I started uploading the images I need to use, the thumbnails are not showing. Figured out everything else I need but this.
Please let me know.
March 31, 2013
Does timthumb require touch() to function properly?
Been beating my head against a wall for some time trying to get it to stop erroring out. Wondering if that is why?
April 4, 2013
So it turns out that the script breaks if you don't have touch() enabled...even though as far as I can see it only uses touch() for error checking. In other words if touch() is disabled (common for security) the error checking effectively breaks the script even if it'd otherwise be working fine.
Please include this in your troubleshooting guide! I wasted probably 5 hours pulling my hair out trying to follow the (non applicable) error messages, thinking I had somehow reconfigured something.
If anyone else runs into:
April 4, 2013