TimThumb Troubleshooting Secrets

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

lightbulbThis 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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. Cache Directory Permissions - the cache directory should exist inside the same directory as TimThumb. It should have permissions set to 777.
  6. 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.
  7. 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.
  8. 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).
  9. 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.
  10. 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.
  11. Image Formats - make sure that the images are one of jpg, gif, or png or they won't be resized.
  12. 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.

Share This...

TimThumb Technical Support

Need help with getting TimThumb to work? Check here for my prices.

Support ›
About The Author

Ben Gillbanks

Web Designer, Video Gamer, Blogger, and part time Entrepreneur. Read More

395 thoughts on “TimThumb Troubleshooting Secrets

  • Reply ›
    Licarium

    Que es TimThumb, y solo se usa en WP ?

    Saludos y no se como llegue aquí.

    December 11, 2012

  • Reply ›
    Norskott

    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

  • Reply ›
    Ern Fraser

    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

    • Reply ›
      Ben

      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

      • Ern Fraser

        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

  • Reply ›
    Nick Thorsch

    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

  • Reply ›
    mitchell

    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

  • Reply ›
    Gordon Werner

    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

  • Reply ›
    Marc Forrest

    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

  • Reply ›
    nick

    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

  • Reply ›
    jay

    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

  • Reply ›
    Achim

    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

  • Reply ›
    Nicole

    I have followed all steps.
    But he still shows me no thumbnails. : (
    Can someone help me please?

    February 22, 2013

  • Reply ›
    Nicole

    sorry i forgot a screenshot ..

    All pictures are shown in the preview in full size: (

    February 22, 2013

  • Reply ›
    Frank Schmidt

    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

  • Reply ›
    ????? ?????

    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

  • Reply ›
    shandyisme

    Hi Ben,
    I have follow all the instruction, but I come up with this one:

    Warning: tempnam() [function.tempnam]: SAFE MODE Restriction in effect.

    A TimThumb error has occured

    The following error(s) occured:
    Could not open the lockfile for writing an image.

    Any Idea? Need Advice.

    Thanks.

    March 23, 2013

  • Reply ›
    jillianmarie

    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

  • Reply ›
    na

    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

  • Reply ›
    ScriptBreaksWithoutTouch

    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:

    Warning: touch() has been disabled for security reasons in /home/fresoil/public_html/templates/ammon/php/img.php on line 200

    Warning: touch() has been disabled for security reasons in /home/fresoil/public_html/templates/ammon/php/img.php on line 469

    Warning: Cannot modify header information - headers already sent by (output started at /your/directory/structure/here/timthumb.php) in /your/directory/structure/here/timthumb.php on line 418
    A TimThumb error has occured

    The following error(s) occured:
    Could not create the index.html file - to fix this create an empty file named index.html file in the cache directory.
    Could not create cache clean timestamp file.

    Query String : src=http://somewhere/image.png&w=290
    TimThumb version : 2.8.11

    Here is what you do to fix it:
    Either enable touch on the server, or simply comment out lines 200-202:

    if (!touch($this->cacheDirectory . '/index.html')) {
    $this->error("Could not create the index.html file - to fix this create an empty file named index.html file in the cache directory.");
    }

    and lines 461-463:

    if (!touch($lastCleanFile)) {
    $this->error("Could not create cache clean timestamp file.");
    }

    This should be fixed or at the very least documented.

    April 4, 2013

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Websites linking here

  1. Favicon for http://www.google.com/s2/favicons?domain=wpcandy.com Community links: “New in 3.1 trunk” edition | WPCandy
  2. Favicon for http://www.google.com/s2/favicons?domain=wpmag.com wpmag.com - WordPress News, Themes, Tutorials, Plugins, Questions, ...
  3. Favicon for http://www.google.com/s2/favicons?domain=support.hawktheme.com timthumb - 777 and caching « Hawk Theme Support Forum
  4. Favicon for http://www.google.com/s2/favicons?domain=wiki.ecommercesystems.net Installing the Theme « Ecommercesystems Wiki Site
  5. Favicon for http://www.google.com/s2/favicons?domain=www.kismetwebdesign.com Migrating Timthumb
  6. Favicon for http://www.google.com/s2/favicons?domain=leotomas.com Leo Tomas's | Timthumb error: thumbnails not displaying on WP3.5
  7. Favicon for http://www.google.com/s2/favicons?domain=www.mcnab.co TimThumb- 500 Internal Server Error, Permissions, Wordpress Freelancer Leeds
  8. Favicon for http://www.google.com/s2/favicons?domain=techforumnetwork.com Timthumb image thumbnails not appearing on wordpress site - Tech Forum Network

My Projects

TimThumb - Image Resize Script TimThumb

Image Resize Thumbnail Script

WPVote - WordPress Social Voting WPVote.com

WordPress Social Voting Site

About me

About BenMy name is Ben Gillbanks. I'm a lover of Video Games, WordPress, Web Development and everything in between.

I have been working on the internet since 1998, and working with computers even longer. I am a hardcore Nintendo fanboy and have owned most of their consoles at one stage or another.

Read more about me on my about page.

My Tweets › Binary Moon

Random Link-outs

Keep Updated

Subscribe to RSS

Stay Updated

Binary Moon

WordPress and Web Development › home of Ben Gillbanks