217 thoughts on “Using TimThumb part 1: Getting Started Leave a comment

  1. Dang! *blushes* You mentioned me in this post.

    To be honest, most of us Premium Theme developers owe you big time. What you’ve built is genius and extra ordinary. I can’t praise this enough. Here’s how this can be taken to next level.

    1) ofcourse the folders needs to be given 775 / 777 permission. ‘Somehow’ if we can find out a way to skip this step, it would take off atleast 25% of our support burden :). I know you might be facing this same problem at Pro Theme design as well.

    2) A way for the user to decide from which direction he/she wants to crop the image. Top left, top right, middle, bottom left or bottom right?

    This is just a wishlist, nice to have stuff that’d make this revolutionary script even better. It’s sad you have not received enough credit for this as this script works behind the door.

    Kudos to you mate.

    1. Thanks πŸ™‚

      Number 1 is an ongoing problem. Not sure how to fix it but I think there may be a couple of things that will help reduce the problem.

      Number 2 – keep reading this series of posts πŸ™‚ There’s actually a couple of things already available that I don’t think people realise are possible, and the one you mentioned will be released in the next couple of weeks.

  2. I am trying to use this in my site but it display images upload in directory wp-contents/uploads , most of the images in my posts are from external site or flickr . It is not displaying thumnail from those site. Is there any thing to make generation of thumbnail from them possible ?

    1. Flickr should work now, other sites will need some customisation. I will be writing a post on this in the next week or two.

  3. Fantastic!, I’ve been using this script in it’s basic form for a long time, I can’t wait until the next installment – looking forward to it thanks

    1. Hi – the script works perfectly with WordPress 3, the version of WordPress doesn’t matter. The problem is in the script itself, and this change is being added to the next version.

      FWIW The author of TimThumb is actually me, and the person you have been talking to is Darren – who forwarded your message to me πŸ™‚

      1. Hey Ben!

        Well.. Glad that’s been straightened out! πŸ™‚

        I was under the impression there was a problem integrating the script into WP 3.0 and hacks are abound (such as the one I posted).

        I subscribe to your RSS feed so I take it I’ll be notified when you release the new & improved version of TimThumb.

        Thus far, it’s the easiest and most effective script to accomplish on-the-fly resizing of images.

        Good to meet you!

      2. Hey Daniel. There’s no problem with TimThumb and WP3.0, I use it here on Binary Moon just fine πŸ™‚ I am going to be writing a series of posts about TimThumb (this is the first) and will announce when I release major new versions (not small bug fixes) so you will see the big updates come through … and there will be one shortly.

  4. my first exposure to timthumb was after I purchased the nominate theme. It’s very neat! I look forward to future posts on it. Maybe I’ll find if there’s a way to add a custom loading or default image if it can’t load something… πŸ™‚

    1. Hey there – glad you like it, and thanks for buying Nominate πŸ™‚

      The default image is really up to the software. TimThumb just resizes stuff but you can have some code in your website that says (pseudo code time)

      If theres an image
      load timthumb image with image I found
      else
      load default image

      If you were to use the Elemental theme, without Nominate, then you would see this code is in place. I demoed it in the recent Elemental update video that you can see here.

    2. Where is

      function displayError($errorString = ”) {
      header(‘HTTP/1.1 400 Bad Request’);
      die($errorString);
      }

      Put this

      function displayError($errorString = ”) {
      $img = @file_get_contents( “no-img.png” );
      header(“Content-type: image/jpeg”);
      echo $img;
      }

      1. Thanks for the suggestion. The problem with that is it doesn’t tell me what error has caused TimThumb to error out which is the whole point of that function. The theme or website should know whether there is an image to resize or not (it’s 1 or 2 lines of code!) and should then supply a default. It’s not up to TimThumb to do that.

  5. Pingback: Using TimThumb Part 2: External Websites
  6. Pingback: TimThumb Image Filters
  7. How to set the second try access the thumbnail image are direct to cached thumbnail?

    why i ask this, is to reduce request http to timthumb.php.

    Regard,

    dgrut

  8. I have confusing for 3 day because timthumb in my website doesn’t work, But now everything is fine. Thanks for this blogs administrator.

  9. Awesome! I’ve just found this script (bit late to the party I know) and it’s going to make using custom fields in WordPress so easy and so great.

    Once again I’m reminded of the generosity and community spirit online. I love it!

    Thanks so much for sharing this awesome gift!

  10. Hi,

    I moved my website to another domain name and server and now none of the thumbnail images show up and I have tried to the delete the cache folder but no success.

    Any chance of getting this to work?

    Thanks,

    Dennis

      1. It depends how the theme works and the image is stored but my guess is it’s a custom field in which case the changes are all in the db.

      2. Hi Ben,

        I have gone through the database and edited all the entries. I have also tried to create a new page with a newly uploaded image (it exists) but it still says “file not found”. If I go to the image without thumb.php it works but otherwise it doesn’t

        Is there anything else that I can try?

      3. Hi Ben,

        After doing some more debugging I discovered that If I change the original path from this:

        thumb.php?src=http://mysite.com/dir/wp-content/uploads/2010/09/forward-to-a-friend-icon.png&h=200&w=350&zc=1&q=80

        to this:

        thumb.php?src=http://mysite.com/wp-content/uploads/2010/09/forward-to-a-friend-icon.png&h=200&w=350&zc=1&q=80

        It works but why is it doing this everything else is working so the path must be correct otherwise wordpress would not work. But there must be something that is causing this.

        Thanks for all your help so far.

        Kind Regards,

        Dennis

      4. Hi Ben,

        Well after moving servers yet again it now seems to work without any modification which means it must have had something to do with the last server configuration.

        Anyway thanks for your reply’s and this nice “plugin”

        Thanks,

        Dennis

  11. I would like to specify the the aspect ratio be maintained at a certain max. width, max. height. I don’t think timthumb can do this, but I’m having trouble with the code for it. Would you help me, please?

    Thanks!

  12. Hi, I love the script. It’s really helpful.

    I have a situation where I don’t want to use a default image for posts that don’t contain any images.

    How can I remove the default image?

    -Add a CSS class that only applies when the script outputs default image?
    -Stop the script from outputting a default image altogether? How would I do that?

    Thanks again for the great work!

  13. I’m using this on a child theme of the Kubrik theme (WP 2.9.2). I can’t get the image to actually show. The code works and gives me the related post, but not the thumbnail. Any thoughts?

    The website is not live yet, so I can’t link you to a working site, but I can send my single.php code over.

  14. Hello, sorry to bring this up here.
    I’ve locally developed a website that uses timthumb and all worked fine. After moving it to my server all pre-server thumbnail calls are failing. New posts with new calls are fine. In the database the values all match, The images were ftp’d up in binary mode. I can’t see a reason for why this is happening?!
    Cache directory has been test at 775 and 777.
    If i try and directly accesss an image the page just displays white with the img url.

    I get the impression that it’s unable to read the file as if it is corrupt. I have uploaded them several times. Any ideas? It’s an image heavy site so redoing all the pages is a big task. TIA

    1. Do you have a link I can look at? Without seeing it I’m not sure I can help. One tip – if you right click and open a broken image in a new tab/ window, then it should tell you what the error is.

      1. Thanks for the tip!
        I’ve actually got it working now. If it helps anyone else…. the generated thumbnails were present and working when acessed directly, the original however had some how become corrupt – 0bytes on the server and uploading new copies just wouldnt work. Windows(7) was reporting these originals (which had been through timthumb) as inaccessible due to permissions (even though I’m admin and creator).

        I don’t know exactly which part fixed it. I used the TakeOwnership.reg Windows7 context menu mod to retake/reown the uploads directory then I scrapped the server install, setup a new vanilla wordpress and uploaded the modified database as usual. Copied ONLY the wp-content folder. It now works perfectly – even bugs that should be there aren’t. I tried manually reowning an image, uploaded, but that failed. So it was either the REG mod or theres code outside of the wp-content directory that was breaking it. I hope that helps someone else who might be having the same problem.

        Great job on timthumb, I gave up on WP years ago because of the poor image support. Now I use it for most sites. Thanks again.

  15. Pingback: TimThumb troubleshooting help
  16. Hi,

    I searched a lot before deciding to come directly to the source. CanΒ΄t find someone reporting the same problem as i have, so..maybe you, as the author of the script, can give me some tips as how to resolve my problem.
    My images show up, they just dont resize.
    Heres a link to a page where the images show up but donΒ΄t resize.
    http://locais.porto24.pt/wp-content/themes/GeoPlaces23/thumb.php?src=http://locais.porto24.pt/files/2010/11/mui_gourmet2.jpg&w=150&h=100&zc=1&q=80&bid=6

    I found that images outside the “files” folder get resized: http://locais.porto24.pt/wp-content/themes/GeoPlaces23/thumb.php?src=http://locais.porto24.pt/wp-content/blogs.dir/6/aikido.jpg

    Thanks in advanced

    1. Hi – The script has nothing to do with validation. The problems are how I did the code for that page. If I had bothered to spend the time to encode everything properly then it would validate just fine.

  17. That was fast answering!

    I refer to the error concerning the output of ampersands as separators in the PHP. How do they output in your script?

    Thanks

    1. The TimThumb script doesn’t output any html – all the script does is resize the images. The html on the page is the problem with the validation and the issues with that are unrelated to TimThumb.

  18. Hey,

    I was just wondering if it possible to specify a default image to the script if no image is found.

    If you look at the theme I am using (Arthemia, url in name) the carousel still tries to use timthumb on no image. I have created a 404 image to go in place, but I cannot figure out how to get timthumb to load the default image if no image is inserted in to it.

    1. Personally I think this is up to the theme to specify. If there is no image available to be resized then it should either hide the image or show a default. Either way you would need to customise the theme to make this work.

  19. Hello everyone .. how to set image height in code so this should apply to all website thumbnails .. sorry but i am not good in programing .. anyone please help .. thank you

  20. Hi – Having a real problem with the thumbnails since a server ‘upgrade/switch’ at the weekend. TimThumb was working brilliantly before that. All the links to existing images are now broken and the script is failing somewhere. Host says GD image has been re-installed on new server. Cache and temp are at 777 (have followed all the advice above). Still no joy. Please help! Thanks.

      1. Thanks Ben for such a quick reply, I checked with the theme developers a 2nd time, they recommended to make the Script and Cache folders 755 in case the server setting was the problem – so I changed those plus the “parent” folder and bingo! it works! I am so relieved. It’s a great script – Thanks

  21. Ben, thank you! Excellent script! I found it more flawless then SLIR (another smart resizer). At first I’ve been trying to set up SLIR for 2 days and it was all in vain. I don’t know why? And then I just suddenly found your Timthumb and… it works!!! perfect!
    I appreciate your code sharing! And whenever I’ll use Timthumb I’ll mention you and link to your blog!
    All the best to you!!!

    1. Glad you found it useful! πŸ™‚ I published a bunch of updates today that improve security and add new scaling abilities.

  22. Hey guys,
    Great plugin I think its the way to do thumbs in webapps with all kinds of sized thumbs being displayed.

    I was wondering though if its a good idea to add to the show_cache_file:

    header(“Location: “.$cache_file);

    instead of reading the file in via PHP, I’m not 100% sure weather this would be faster then just using PHP but I just think if the image has already been cached then its a shame to go through PHP to retrieve it.

    No expert on this so critics welcome πŸ™‚

    1. Hi John – thanks for the idea, that’s quite clever actually. Unfortunately that probably won’t make any difference. The issue is that unless the theme/ script stores the cache location itself you will always have to hit the php file to be able to work out if there is a cache file or not.

      I do have one idea that involves creating a function that will generate the cache file and return the cache name so that you can store it in your web app (in WordPress post meta for instance) and then display that instead of hitting timthumb every time. This, however, would be less flexible so may not be so good.

  23. Hi Ben,
    thanks for your great script, it was part of a WP-Theme I installed, and I’m lovin’ it.

    Is there any possibility, to tell your script to fit either the width or the height, and to stop fitting after the first one matches? I have a problem with photos in portrait mode or in a square crop, check out my blog, there are two pics, which are zoomed in a lot, and I wonder if this is the only solution for such photos, if I want to keep the aspect ratio…
    Sorry for my bad English, don’t know if you get what I mean.

    Thanks again, hope to hear from you…

  24. I recently migrated from Blogger to WordPress. My site is techlikes.com. I’m using “Arthemia premium” theme v1.0. Since I found that the TimThumb script in the theme folder is old, i updated it with new TimThumb script from googlecode site. But the images are not showing up and no error crops up. Can you please check what is wrong ? site is techlikes.com and mail id : rama.geek AT gmail.com

  25. I have a problem with photos in portrait mode or in a square crop, check out my blog, there are two pics, which are zoomed in a lot, and I wonder if this is the only solution for such photos!!

  26. Hello,

    Great script, useful and very simple to use!

    The only thing it’s missing is a way of dealing larger files you don’t want to crop and of course, distort them.

    Imagine you are printing some logos. You can’t cut parts of a logo and of course you must keep the proportions of the original logo. If there is a jpeg file it should use some standard fill color and, if it’s possible, it png files it should use transparent background.

  27. The case Jan and me were talking is when the image needs a fixed size where one cannot use just one of width/height parameters to keep the original w/h ratio.

    The logic could be like this:
    if original_width/new_width larger that original_height/new_height
    then use new_width and calculate height to keep original w/h proportions;

    1. I actually added this yesterday. Try adding parameters zc=2 and zc=3 (each has does slightly different things) to the resize url. Will be writing this up in the next week or two πŸ™‚

      1. Thanks a lot Ben,
        now with V 1.25 it works very fine with zc=2 for me! Very great!

        Thanks thanks thanks!

        Bye

  28. This is nice, thanks!

    I’m already using the latest version. Could there be a parameter to choose the color it’s using on blank spaces of shrinked JPG files? (it uses black now; transparent png24 files are working fine)?

  29. Hello Ben, thanks for making WordPress worth the trouble. They should consider hiring you or buying your script because their thumbnail script is complete garbage.

    I have a simple question:

    Is it possible to move the center of the image to the top or bottom, instead of the exactly in the middle?

    Thanks!

      1. Glad you worked it out! Regarding buying my script – it’s open source, they can use it for free if they want πŸ™‚

  30. Hi,
    I love your script, really do, once I got my head around it the first time I love to use it to resize all my photos.
    One problem I have come across is that its not W3C Valid. Please could your look into this.
    Thanks
    Rachel

    1. Hi – the script it totally w3c valid. In fact there’s nothing to validate with the script – the issues are with how you are using it so you will need to change the implementation method to make sure it validates properly.

  31. Love the script – been using 1.12 for a while now… but whatever I do I can’t get 1.25 to work for me. I’ve copied the new script over, made the new temp folder, and checked everything three times but it simply won’t work. If I revert to 1.12 though, it’s fine. Any thoughts? Here’s the line in my template file that calls the script:
    <img src="http://URL-TO-FILE/timthumb.php?src=&w=400&h=255&zc=1&q=100” id=”leadpic” alt=””>

    1. Hi Andrew – your code looks fine. What error do you see when you use the latest version of TimThumb? Just open the image in a new tab and there should be some sort of message telling you what the issue is.

  32. Hello.

    I have problem with resizing the image.

    http://bxk81.youndme.com/wp-content/themes/londoncreative/scripts/timthumb.php?src=http://bxk81.youndme.com/files/2011/03/bigbang-tonight.jpg&w=560&zc=1&h=170

    This is the URL. If you try to open, http://bxk81.youndme.com/files/2011/03/bigbang-tonight.jpg, then it works fine but it says, “file not found /files/2011/03/bigbang-tonight.jpg”

    I created both temp and cache with 777 permission but it is still now working.. Do you know any reason for this?

    Thanks!

    1. one note is that I do use “multisite” in my wordpress.. I feel like the script has problem access the url.. but not sure.

  33. Great script!
    But I have a problem. It’s resizing but cropping the photos, I want it to actually resize it and scale it down.
    Help please? This is the code I’m using

    <img src="/timthumb.php?src=
    &h=100&w=200&zc=1″ alt=””/>

    Thanks ALOT in advance!

  34. I tried to solve the problem but still, no thumbnails appears in my website. Anyway, my readings still not finish its just step one. hope if i finish learning timthumbs from this blog hope it will take effect on my site. it needs thumbs so so bad!

  35. hy, is it possible to have a color profile in images like sRGB? Cause the fallback of mac os for images without profile is to use the monitor profile. if you have a wide gammut monitor the colors look very oversaturated. sRGB colorprofile solves this problem.

    any hints?
    thx&greetz

  36. I bought a wordpress theme from rt themes that incorporate Tim Thumb. I am using it on rishriners.com I just updated my server to php 5.2.17 and now the images don’t appear. Is this a Tim Thumb issue? Any help will be great.

  37. Using the Automotiv theme it’s generating thumbnails and images just fine on my local xammp install, but the identical install hosted with bluehost is a no show (file not found error when you right click) – the URLs are identical.

    Versions 1.23 and 1.25 both don’t display. I’ve played with folder and file permissions and it’s quite easy to get a 500 internal error for the image when using 777 for the file or the scripts folder. 755 sorts that error but still throws out a file not found on right click.

  38. Just out of interest, I just tried uploading this modified version of the file (it’s linked to in the first comment) and it’s now working:

    [link removed because the content is out of date]

    Maybe that’ll help somebody far cleverer than me to figure it out!

  39. Hi,
    I’m using timthumb for my website, however images don’t load in the main page. I’ve tried changing permissions, even tried to see it there was something wrong with the theme code, but with no success.

    Here’s the link to the website i’m building, it’s all about images here and I can’t seem to make it work. http://beta.artmania.ro/

    1. Alexandra, if it still doesn’t work with the last version, send me an email (in Romanian) on contact page on my site (click on my name). I have it running on 5 sites and even there were some small problems when I started, in the end I have them all working fine.

  40. Actually Alexandra’s problem is caused by printing a warning introduces in php 5.1.0:

    Note:
    Since PHP 5.1.0 (when the date/time functions were rewritten), every call to a date/time function will generate a E_NOTICE if the timezone isn’t valid, and/or a E_WARNING message if using the system settings or the TZ environment variable.
    (http://php.net/manual/en/function.date-default-timezone-set.php)

    You must not use the system default time if you want the warning not to show. In her case a simple
    date_default_timezone_set('Europe/Bucharest');
    added to line 529 fixed the problem.

    I think you should treat this issue in the following releases as it might affect others, too.

    1. Thanks for the tip – I wasn’t aware of this.

      In this case I would have thought the easiest way to stop the errors is to suppress error messages entirely (error_reporting(E_NONE)?

      1. True, it might have been easier, but as I think it’s there because it’s needed in this moment πŸ™‚

        Just imagine that all people debugging their scripts cannot use timthumb until they completely removed all other php warnings/notices/errors.

        This is why editing the timthumb might be a better solution πŸ™‚

  41. Hi, Binarymoon.

    I’m a new WordPress user .
    Now I’m using a theme which use timthumb to generate a photo-gallery.
    Everything’s just fine but I need to edit the size of images which generated by timthumb to suit what I need.

    The problem is :
    I can’t find the place of the code who made the thumbnail call in the theme.

    I’ve searched for lines which look like:
    /scripts/timthumb.php?src=http://…./uploads/image.jpg&w=600&h=400&z=1
    in my index.php and single.php but still I can’t find it.

    Any suggestion?
    (Thank you)

    1. I’m afraid you will need to ask the developer of the theme you created how TimThumb is used. I can’t really help since the code could be anywhere in the theme.

  42. Hi
    I have a question please;
    Now tha I’m using a template with (Timthumb) (wordpress) it is generating the thumbs fine for new posts, but how can I get it to generate thumbnails for older posts?
    I have arround 350 articles!!!
    Thank for your help

    Ramzi

    1. Hi Ramzi – theoretically your theme will do the thumbnails for you. If not then you will need to ask the author of the theme to help. I can’t help with making the theme find thumbnails.

    1. You are not using TimThumb on your website – so the resizing is not going to work. You also seem to be using a lot of proprietary Internet Explorer filters which is really bad for browser compatability.

  43. Thank you! I love this script!
    But is there anyway to change the default width, height, and quality?

  44. Hey nice tutorial , i wanted to know how can i use this script in wordpress?? with the post-thumbnail feature?

  45. Hi Ben,

    I’d like to use your script. I uploaded the TimThumb meets MCE plugin to my WP and activated it. I found your site because the image resize button in the WP MCE didn’t appear/display in the post I am creating. I do have the latest version of WP. The blog’s theme is flexsqueeze2.

    You suggest that I use the timthumb.com script at http://timthumb.googlecode.com/svn/trunk/timthumb.php. I do notice that the above script is different (and appears more current) that the script contained in the WP plugins that I uploaded to my blog.

    Could you tell me which script I ought to be using? I also noted that the plugin script doesn’t contain a “temp” folder but it does contain a “cache” folder. And, I wonder if the default permissions for these 2 folders are 775 or 777 — which is it? You did state that this script updates regularly so it’s good to signup for updates.

    1. Hi Leslie – the version on Google code is always the most recent. Always use that one, it has a number of speed improvements and security enhancements that older versions don’t

  46. Oops! I almost forgot. I want to crop images but again, I’m unsure which of the 2 TimThumb scripts permits me to do this. Cheers to you. πŸ™‚

  47. Hi guys, I had a problem because to use the function strtotime() needs to be defined the timezone.

    If anybody gets the same problem only need to define the timezone at the begining of the php file where save the code of the library.

    date_default_timezone_set(‘America/Guatemala’);

    Only for information prouposes I use lampp server on Fedora 15, maybe the configuration by default of the server can throw this error.

  48. Hi

    Do you think that TimThumb is a solution when dealing with heavy load websites? Does it affect the speed-load and by any chance create a bottleneck?

    Thanks

    1. Any dynamic content will add more processing requirements and load time to a website. In this case it will be slowest when the cache files have not been created, and the user has not visited the page.

      I can’t say how it will affect your website though. The only thing I can say is to make sure you keep up to date with TimThumb versions. I update it quite regularly and always try to speed it up, and make it more secure.

  49. Hi Ben,
    I am having issues with SOME thumbnails. I created a test page displaying original and thumbnail side by side. You can see the thumbnail on line 1 is broken.

    Go here: http://thasneen.com/cooking/thumb-test.php

    Any idea? I have been trying to figure this out for the last couple days with no success.

    ps:
    On my website the thumbnails stopped working for all posts from the 1st week of Jan 2011 and all posts BEFORE that. The newer posts are all fine.
    http://www.thasneen.com/cooking/2011/01/

  50. i upgraded to timthumb version 2.0 and still no go. the images are there in my uploads directory but all thumbnails are failing for posts older than Jan 2011.

  51. I don’t seem to see whether your program can deal with both vertical and horizontal images to retain their aspect. I have a store and there are currently 1500 thumbs to be loaded, some have been shot vertically – for clocks, while others were shot horizontally for tables and other furniture. Is this the right program for me?

  52. Hi Ben, I’m not sure to understand how TimThumb works after merging WordThumb. Do I always need a cache directory with CHMOD 777. And the temp directory for the external files? I see you can leave the value for cache directory blank. What is the difference?

    Thank you

    1. If you leave the cache directory blank then TimThumb will use the server temp directory. This is not always usable (based upon server configurations) so the cache directory may sometimes be required.

  53. Hi,

    I hope you can help! I’ve been using timthumb as part of a Theme purchase and recently upgraded the theme and none of the images are now showing on the posts, although they are there and they open up quite correctly when clicked.

    I changed the timthimb.php file according to the google code link you supplied and I had to manually add in a cache & temp file to my scripts folder. I’ve messed around with 775 and 777 for these but still the images aren’t displaying.

    Have you got any suggestions how to get it working? Do I need some sort of cacheing script?

    Thanks!
    Sam

  54. Hi, I am having the same situation as Sammiej in the post above. On a client’s site, the thumbnails no longer show but he says they used to. The site is http://www.brainpcgames.com. I found this post about the timthumb 2.0 update as related to the theme http://wparcade.com/blog/ and followed the instructions to replace the timthumb.php file and add the index.php and htaccess to the cache folder. Also tried all of the permissions changes suggested, and made sure that no directories above the timthumb file had 777 permissions. Is there something else I can look for?

    Thanks a ton!

  55. Pingback: Tim Thumb Shortcodes | Caramboo Dot Com
  56. Hi,

    I have a problem. I buy a template from Theme Forest which use the timthumb script. There is, like described, two folders (cache and temp) in the same folder than the timthumb.php file. These have the 777 permissions.

    But in front end it doesn’t work. When I lokk with firebug, it indicates “Failed to load the given URL”. The image is well in the temp folder but not in the cache folder.

    Could you help me because the support of Theme Forest doesn’t.

    Thank for advance

    Papou

  57. Home does not show my picture! I do not know what the reason, many methods are used! Is not! Help me look at it? I ie315.com! Thank you!

  58. Hi!

    I check around your site to look what’s my problem but i’m still not able to make my blog work properly with WP and timthumb.php. You can take a look at latexpirate (dot) com and see that we cannot see the image at the good place. As soon as I put the timthumb.php code I receive a x icon. All my stuff are 777 right now and I also try it to 775 and 755. I really need help please. Thanks!

  59. I have purchased a theme that uses the TimThumb script in the opening slider. I am experiencing issues with the images not loading. Refreshing the page produces similar results. It is not always the same image. I have tried changing the permissions from 755 to 777 in both the cache and temp folders in the php file included with the theme. This did not help, and my host recommended that I use 755, so I changed it back.

    The images are stored in a folder on the public_html root directory on my server entitled /images I have tried changing the jpeg file size as well as made sure that they were not loading progressively. This also did not help.

    The theme uses a user interface where I can enter the image URL. I have tried both relative and absolute image paths.

    Perhaps, you could take a look at ipa-connect.com ~ any help would be greatly appreciated. I am at a loss.

  60. I am unable to get it work Under IIS 5, I always get “HTTP Error 400 – Request is badly formed. Internet Information Services (IIS)”, you can see it on “http://www.mundoplano.com/public/timthumb.php” and the info “http://www.mundoplano.com/public/info.php”

    Thanks in advance for the support

    Alex

  61. If i wish to specify the width alone and height as auto means, how can i specify that in the img src? Please give the code with an example. Thanks for your product. I really like timthumb which help us in resizing the images

  62. Hi, great script but i need to use timthumb like this:
    Ex: thimthumb.php?src=getImage.php?imageID=122
    or: thimthumb.php?src=getImage.php%3FimageID%3D122

    something like that, but it gives this error: Could not find the internal image you specified.

    Thanks in advance… keep up ^_^

    1. That’s not going to work. The only possible way to do this would be to make the url absolute (include the domain at the start) and to wrap the url in url_encode so that the parameters don’t confuse the script.

  63. thank you for such a great script.
    I was wondering if it causes server overload if i use this script massively in my website.
    For ex: I use this script to generate around 50 – 60 image thumbs in a single web page.

    Have you experimented in this?

    1. Anything can overload the server if you abuse it πŸ™‚

      That said – I have tried to optimise it as much as possible and with browser caching and whatnot it shouldn’t be too bad after the initial image creation.

  64. You’re product it,s great.

    I have a error when i want put some parameters (ex: for change the height &h=150 )

    My code
    images/Condo200-116-1.jpg
    TimThumb/timthumb.php?src=images/Condo200-116-1.jpg&h=150

    The version of my script VERSION’, ‘2.8.3

    Thanks

  65. Thank you for making this great script. Is it possible to make a mini-timthumb that only has the basic resizing features?

    I have a website with about 100k visitors and 500k pageviews. I have seen this script go from 18k to 50k, without features I never use.

    Currently timthumb is consuming around 35GB of traffic every month and it would be great if there would be a 20k mini-timthumb with the basic features.

    1. Hi Lisa – the size of the script shouldn’t matter too much since it doesn’t actually get downloaded. I am certainly considering ways to simplify the code but I don’t plan to make a mini version. If someone wants to fork it and make a simpler version they are more than welcome to.

  66. Ok, I’m using your code to create a thumbnail of an image, but when the image is smaller than the expected thumbnail, it is ENLARGED, what I do not want. How can I say to your code “DO NOT RESIZE” if width is less than a certain threshold? Thank you in advance.

    1. The script is designed to resize to the dimensions you specify. As such it will sometimes resize images. You would need to try changing the zc value to get different effects, but there is no ‘do not enlarge’ option I am afraid.

      1. OK I used getimagesize to get the size of image and conditionally call TT url or image one.

  67. Hi, My error log is filling with these out of memory errors:

    [29-Dec-2011 18:18:25] PHP Fatal error: Out of memory (allocated 262144) (tried to allocate 77824 bytes) in /home/ikwilfil/public_html/wp-content/themes/mad/lib/scripts/timthumb.php on line 585
    [29-Dec-2011 18:18:28] PHP Fatal error: Out of memory (allocated 262144) (tried to allocate 77824 bytes) in /home/ikwilfil/public_html/wp-content/themes/mad/lib/scripts/timthumb.php on line 585

    I have already edited the memory limit in timthumb but still get the errors, i am using v2.8.5. please help

    regards,

    jaapo

    1. I suspect it’s happening because your image is too large. If you make sure the images are not too big before you resize them then you shouldn’t get this so much.

  68. Hi,

    I am trying to use timthumb on one of my websites which is on a shared webserver with virtual hosts in apache httpd.conf (windows).

    The issue is that the document root retrieved by

    $docRoot = @$_SERVER[‘DOCUMENT_ROOT’];
    if (defined(‘LOCAL_FILE_BASE_DIRECTORY’)) {
    $docRoot = LOCAL_FILE_BASE_DIRECTORY;
    }

    Seem to not work.

    If i disable virtual hosting timthumb works instantly on local images stored on the webserver, but with virtual hosting enabled it seems timthumb cannot find the proper document root.

    Is there anyway i can manually insert my document root instead of having php trying to fetch it through command?

    Thanks.

    1. If you add a file called timthumb-config.php in the same directory as timthumb.php then you can override settings like this. In this case there’s an override called LOCAL_FILE_BASE_DIRECTORY so if you set a new define in timthumb-config with the correct value then hopefully it will work.

  69. My issues were deeper and more advanced then i though, i did some debugging and found the issue.

    The issue i have is that my images are served over htaccess which rewrites the original paths, however those requests are only rewritten if its coming from http.

    If i put the images on the same domain as the wordpress the timthumb script will try to use the local function to access the images resulting in them not being found.

    What i need to do is to somehow rewrite the local function to work exactly like the external function.

    I made a ticket for my issue here:

    http://code.google.com/p/timthumb/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Summary&groupby=&sort=&id=315

    Took awhile for me to figure this out, sorry for the confusion.

  70. I fixed my issue by modifying the script at line 229:

    remove $this->src = preg_replace(‘/https?:\/\/(?:www\.)?’ . $this->myHost . ‘/i’, ”,$this->src);

    and it will treat same urls as external.

    I have a follow up question, how can i make sure that the script NEVER clears the cache and NEVER looks for a new thumbnail once the thumbnail has been generated?

    I set

    if(! defined(‘FILE_CACHE_TIME_BETWEEN_CLEANS’)) define (‘FILE_CACHE_TIME_BETWEEN_CLEANS’, -1);

    if(! defined(‘FILE_CACHE_MAX_FILE_AGE’) ) define (‘FILE_CACHE_MAX_FILE_AGE’, -1); // How old does a file have to be to be deleted from the cache

    if(! defined(‘BROWSER_CACHE_MAX_AGE’) ) define (‘BROWSER_CACHE_MAX_AGE’, 8640000000000000000000000);

    But it still feels like its sometimes regenerating the thumbnail.

    Thanks.

  71. So I’ve been playing with this all day and am ready to tear my hair out. I’ve installed timthumb and have set my cache and temp folders (which are residing, along with the timthumb.php script in wp-content/themes/my-theme) to 775 – I originally had them at 777 but still it wasn’t working.

    I have a search function that spits back a selection of posts and I’m trying to get the thumbnail to show up for the post using the following code on my category page (which is the search result page)

    <a href="” rel=”shadowbox;width=930;”><img src="/timthumb.php?src=&w=206&h=104&zc=1″>

    My result page is coming back fine – but there are no thumbnails. When I check the cache folder, there are no thumbnails in there, nothing in the temp folder either. What am I doing wrong?

    Is there a secret to adding the images in the WordPress post, have I completely screwed up my code. Please help me I’m desperate.

  72. Ahh okay the code doesn’t come out right there. The code should read (excuse the php code not being written correctly – I can’t think of any other way to write the code in here properly – on my files the code is bang on target):

    <img src="/timthumb.php?src=&w=206&h=104&zc=1″>.

    1. Hi TIna – if you’re using the_permalink then you’re setting the image source to be the url of the post, and not the url of the thumbnail. If you can get the post thumbnail url and use that instead it should start working.

  73. Trying one last time with the code:

    <a href="" rel="shadowbox;width=930;"><img src="/timthumb.php?src=&w=206&h=104&zc=1">

  74. I have tried everything to get TimThumb to work with the Seventeen WordPress Theme from Alex Pascal. Have checked the directories temp and cache and their permissions. None of the graphics scales.

    Not sure what to so next :0

    Any help will be appreciated

    Regards
    jeffrey

  75. I am using 1and1 hosting and keep receiving this error “URL file-access is disabled in the server configuration in..”. I read somewhere it’s because the new PHP 5 has by default the command “allow_url_fopen” turned OFF.

    Is their a hack or anyway still possible to use TimThumb?

  76. Hi Ben.

    My timthumb.php could not show any images on the website, caused reason probably the webserver ( but system admins would not repair.. πŸ™ ).

    sys admin says: “your script going to deep ( up ? ), where you do not have permission at all…”.
    ” File(/servers/httpd/htdocs/ujlap/wp-content/uploads/2011/09/image-127.jpg) is not within the allowed path(s) ”

    must be like this: “/USER/autouveg-soos/autouvegsoos.hu/www/ujlap/wp-content/uploads/2011/09/url9.jpg ”

    theme developer says: ” problem with server , ask sys admins to fix it..”

    the website: ” http://www.autouvegsoos.hu/ujlap/car-listing/

    ERROR :
    http://www.autouvegsoos.hu/ujlap/wp-content/themes/radial-theme/timthumb.php?src=http://www.autouvegsoos.hu/ujlap/wp-content/uploads/2011/09/image-127.jpg&w=613&h=180&zc=1&q=100

    output:

    “Warning: realpath() [function.realpath]: open_basedir restriction in effect. File(/servers/httpd/htdocs) is not within the allowed path(s): (/USER/autouveg-soos/:/servers/php/lib/php:/tmp/phpupload:/tmp/phpsession) in /USER/autouveg-soos/autouvegsoos.hu/www/ujlap/wp-content/themes/radial-theme/timthumb.php on line 815

    Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/servers/httpd/htdocs/ujlap/wp-content/uploads/2011/09/image-127.jpg) is not within the allowed path(s): (/USER/autouveg-soos/:/servers/php/lib/php:/tmp/phpupload:/tmp/phpsession) in /USER/autouveg-soos/autouvegsoos.hu/www/ujlap/wp-content/themes/radial-theme/timthumb.php on line 827

    Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/servers/httpd/htdocs/ujlap/wp-content/uploads/2011/09/image-127.jpg) is not within the allowed path(s): (/USER/autouveg-soos/:/servers/php/lib/php:/tmp/phpupload:/tmp/phpsession) in /USER/autouveg-soos/autouvegsoos.hu/www/ujlap/wp-content/themes/radial-theme/timthumb.php on line 853

    How could i change the timthumb.php ” $_SERVER ” to the URL path or change only the relative path to wp-uploads folder ?

    I uploaded an other server, where works like a charm, but client would not leave the above mentioned host provider.

    other: “http:/www.unit45host.com/virtungolas ” pictures show up, without problems, and modification.

    Thank you for help.

    Zoltan

  77. Hi Ben

    I have been reading your site and the google site and the theme site. I have also tried to tweak a few things – which have not worked.

    Currently my site gives me the following error:

    A TimThumb error has occured
    The following error(s) occured:

    Could not find the internal image you specified.

    Query String : src=/blogs.dir/1/files/2010/10/epoch_startscreen03.png&w=520&h=280&zc=1
    TimThumb version : 2.8.7

    Any pointers you could give me would be much appreciated. Thanks

    1. Hi Justin – all the pointers I would give you are in your error message. The problem is that TimThumb can’t find the image, and so you need to work out why. Perhaps you need to prepend /wp-content/uploads/ on the front of the path?

      1. Hi Ben

        Thanks for the response. I thought you might say that as I read one of your post where you mentioned that it should be real quick to identify what the issue might be. From the message I would assume the same thing as well.

        The difficulty I have is how to solve it. Eg. when you say prepend /wp-content/uploads/ to the front of the path – my question would be how do I do this? Which part of the timthumb.php would I be amending this? I am not a coder so I am fairly clueless.

        Thanks again for your time.

      2. Hi Justin. The changes would need to be made in your theme, rather than timthumb itself. So you should look through the files there. Hopefully your theme developer will have coded the site to reference TimThumb in a single place, in which case it will be really easy to change. If not you will need to search through all template files and update accordingly.

  78. Pingback: Complete TimThumb Parameters Guide
  79. Awesome script and extremely useful too, great work!
    Especially since I just found out in your comments about z=3, that was exactly what I needed.

    I implemented it, using a little mod_rewrite to get nicer URLs:

    RewriteEngine On
    RewriteRule ^(.*)\.thumb\.(.{3,4})$ library/timthumb.php?src=$1\.$2&w=150&h=150&zc=3

    (It assumes timthumb.php is located in a directory called “library”)
    And now I can get the thumbnail of “example.com/images/my_image_1234.jpg” by writing “example.com/images/my_image_1234.thumb.jpg” πŸ™‚

  80. Hi Justin,

    Awesome script have nice options resize cache crop… but why script don’t have rotate option for nn degrees?

    Regards

  81. hi,

    Can you help me with this? My domain it’s in development, it’s http://82.102.29.17/~swagpt/

    I think this is generating this problem, in the homepage, the thumbs don’t appear, so I inspected the code, and have copied to new window, the error was:

    Could not find the internal image you specified.

    Query String : src=http://82.102.29.17/~swagpt/wp-content/uploads/2012/03/feat_infografia.jpg&h=272&w=460&zc=1
    TimThumb version : 2.8.10

    Many thanks for your help

    1. Hi – you can’t use it on virtual folders I am afraid. The folder you specified there doesn’t exist and so timthumb is looking in a folder that isn’t there – so can’t find the image.

      1. Humm, I see what you mean, I have to find another solution with my hosting.
        Thanks a lot for your quick response!!!

  82. Hi, Ben. Timthumb used to work brilliantly on my site until my hosting service replaced the script with the patched version. I understand why they needed to do this, but now none of the thumbnails are working.

    I’ve set the CHMOD to 755 on the cache folder. After researching the issue, I think the problem may be that I need to use absolute URLs instead of relative URLS. For example, the link to one of the thumbnails on the homepage looks like this:

    http://www.scentofthemissing.com/wp-content/themes/ColdStone-old/timthumb.php?src=../images/th-trailer.jpg&h=62&w=62&zc=1&q=100

    I’m not a programmer, so I need clear, detailed instructions. How do I edit Timthumb so that it uses absolute URLs for all the thumbnails?

    Do I need to delete the images in the cache after revising the script? Is it safe to delete the images in the cache BEFORE revising the script?

    Thanks for your help!

    1. I don’t know how you have your theme setup but when I tried – just removing the .. from the src parameter worked fine.

  83. Great script! Well done, an excellent tool that would have saved me hours on projects years ago.

    One question: is there a way to crop the image without rescaling? That way if the image (200×200) is larger than the set dimensions (100X100), it just centers on the image and takes that center 100×100 square?

    The reason for this is I notice a slight distortion of images with text, and want to keep the original size intact.

    I can’t seem to find this and would appreciate the capability!

    Thanks,
    Anthony

Leave a Reply

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