TimThumb has always been built with simplicity in mind. However there are a few things it can do that have not been exposed before.
Inspired by a comment from RBhavesh I have decided to write a series of posts in which I will show you how TimThumb should be used - and introduce some new functionality.
In this post I will discuss the basic usage of the script - the minimum parameters to send, and some examples of usage.
Basic TimThumb Setup
Getting TimThumb to work is pretty straight forward. You need the php file, which you can download TimThumb from Google code, placed in a folder on your website. In the same directory as the timthumb.php file you need to add 1 directory. The directory should be called 'cache' and needs to have its file permissions set to 775.
Simple explanation
TimThumb is a single php script that has a series of parameters passed to it through a query string. Whilst TimThumb has found a home in WordPress themes it is by no means limited to them - TimThumb can be used on any website to resize almost any image.
Requirements
For TimThumb to work your web server should support the PHP programming language and the GD image library. In all the time I have been developing TimThumb I have yet to find a server it wouldn't work on, so there's a pretty good chance that TimThumb will work on your server.
In addition you should create one directory for saving thumbnails. This directory should be in the same directory as the TimThumb script and should be named cache. The cache directory should have it's permissions set to 775.
Note that the cache directory should be the only file/ directory with 775 permissions. The script, the scripts folder, and any other folders should have the default value for your server.
Basic Parameters
The parameters below are the main ones used. With these you can resize almost anything.
- src - this is the only required parameter. Absolutely everything else is optional. If you only specify the source property then the image will be cropped/ resized to the default dimensions (which are 100 x 100)
- w and h - width and height. Totally optional but also almost essential, few people want the default sizes. The width and height can be any value, TimThumb will enlarge or shrink as required.
- q - quality. This specifies the compression level of the images being cropped/ resized.
I have put together a page of examples with code, so that you can see all you need to know. You can view the examples here.
With just these parameters you can do everything you need to with the average TimThumb image. In the following parts I will outline the more advanced features of TimThumb including showing off some of the latest functionality.
In the next part I will be showing how to use some of the more advanced features in TimThumb, including how to make images greyscale and other filters.
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.
August 6, 2010 • @rbhavesh
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.
August 6, 2010
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 ?
August 6, 2010 • @pri2sh
Flickr should work now, other sites will need some customisation. I will be writing a post on this in the next week or two.
August 6, 2010
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
August 6, 2010 • @squareonemd
Glad it helped - hopefully the next posts will help too.
August 6, 2010
I'm pretty sure you need to fix timthumb to get it to work in vs. 3.0 of WP. I've actually been corresponding with the Author of the script (Darryl) on getting him to release an official version upgrade.
In the meantime, readers can check out instructions on how to fix the script here:
http://wptricks.net/...fix-readfile-problem-on-timthumb/
August 6, 2010 • @stormbytes
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
August 7, 2010
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!
August 7, 2010 • @stormbytes
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.
August 8, 2010
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...
August 10, 2010
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 imageload 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.
August 10, 2010
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;
}
January 22, 2011
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.
January 22, 2011
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
August 29, 2010
I have confusing for 3 day because timthumb in my website doesn't work, But now everything is fine. Thanks for this blogs administrator.
September 15, 2010
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!
September 19, 2010
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
September 20, 2010
If the domain name has changed then it's likely you will need to update the TimThumb urls to match the change.
September 20, 2010
Thanks for your fast reply Ben,
I am currently using TimThumb as part of a wordpress theme:
What exactly do i have to change? Or it it located in the database?
Thanks,
Dennis
See below for the source of "thumb.php"
http://www.mediafire.com/?yu49n227i707nmi
September 20, 2010
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.
September 20, 2010
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?
September 21, 2010
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
September 21, 2010
not sure - I assume you are using a multisite version of WordPress?
September 23, 2010
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
September 23, 2010
glad it all works
September 26, 2010
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!
October 11, 2010
Be sure thumb.php is not being cached with opcode caching such as xcache or APC. You can filter it from APC in your .ini file, here is more info re: APC opcode caching with WordPress:
http://chrisgilligan.com/...ith-php-running-under-fcgid/
If you are using W3 Total Cache, WP Super Cache or another cache plugin, you can specify filters for scripts or folders that should not be cached.
October 19, 2010
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!
October 19, 2010
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.
October 25, 2010 • @millerslab
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
October 31, 2010
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.
October 31, 2010
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.
October 31, 2010
Glad you worked it out, and glad you're enjoying TimThumb
Thanks for the kind words
November 1, 2010
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/...38;zc=1&q=80&bid=6
I found that images outside the "files" folder get resized: http://locais.porto24.pt/...ntent/blogs.dir/6/aikido.jpg
Thanks in advanced
November 9, 2010
Hi
I wonder, does your script validate? I checked http://www.binarymoon.co.uk/demo/timthumb-basic/ and there were quite a few errors, some of them related to incorrect encoding of ampersands.
November 21, 2010
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.
November 21, 2010
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
November 21, 2010
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.
November 21, 2010
OK, thank you.
November 21, 2010
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.
November 25, 2010 • @thisisfreelance
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.
November 25, 2010
just replying with notifications ticked!
November 25, 2010 • @thisisfreelance
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
December 26, 2010
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.
January 31, 2011
Getting a 404 on the images so either a) the image doesn't exist, or b) you have directories that are above the cache directory, and are set to 777 permissions. See here for TimThumb trouble shooting hints and tips.
January 31, 2011
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
February 1, 2011
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!!!
February 6, 2011
Glad you found it useful!
I published a bunch of updates today that improve security and add new scaling abilities.
February 6, 2011
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
February 7, 2011
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.
February 9, 2011
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...
February 8, 2011 • @Raz0r118
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
February 9, 2011 • @palla2009
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!!
February 14, 2011 • @martinvaresio
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.
February 18, 2011
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;
February 18, 2011
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
February 18, 2011
Thanks a lot Ben,
now with V 1.25 it works very fine with zc=2 for me! Very great!
Thanks thanks thanks!
Bye
March 15, 2011 • @Raz0r118
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)?
February 18, 2011
I haven't done that yet, although I have considered that people will want to change it
It's on the todo list
February 19, 2011
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!
February 28, 2011
Wow I'm such a fail, it's on your site! You can remove my comment if you'd like.
February 28, 2011
Glad you worked it out! Regarding buying my script - it's open source, they can use it for free if they want
March 1, 2011
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
March 2, 2011 • @spanglishwebs
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.
March 3, 2011
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/...00&h=255&zc=1&q=100" id="leadpic" alt="">
March 9, 2011 • @thegate
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.
March 9, 2011
Hello.
I have problem with resizing the image.
http://bxk81.youndme.com/...8;w=560&zc=1&h=170
This is the URL. If you try to open, http://bxk81.youndme.com/.../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!
March 11, 2011
one note is that I do use "multisite" in my wordpress.. I feel like the script has problem access the url.. but not sure.
March 11, 2011
You will need to make some changes for multisite to work properly. Check out the tutorial on setting it up here. http://www.binarymoon.co.uk/...10/timthumb-wordpress-mu/
March 11, 2011
Any pointers you could give me would be much appreciated. Thanks
February 23, 2012
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!
March 13, 2011
Try changing zc=1 to different values. 2 & 3 may do what you need
March 13, 2011
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!
March 20, 2011 • @uhannkd226
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
March 25, 2011
As far as I know this isn't possible I am afraid.
March 26, 2011
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.
March 30, 2011
TimThumb works fine with the latest version of PHP so I doubt it's that
March 31, 2011
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.
April 4, 2011
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!
April 4, 2011
Hi Paul. TimThumb already works with external websites. Just read the docs
April 5, 2011
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/
April 5, 2011
Hi Alexandra - please make sure you are using the latest version of the script.
April 6, 2011
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.
April 6, 2011
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/...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.
April 10, 2011
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)?
April 12, 2011
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
April 12, 2011
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)
April 16, 2011
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.
April 17, 2011
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
May 3, 2011
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.
May 5, 2011
Hey Ben!
I'm having trouble with this code... i've copied your code straight over and I'm having problems.
link:
http://nicholasburge.com.au/img/img.php
Thanks!
May 14, 2011
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.
May 15, 2011
Thank you! I love this script!
But is there anyway to change the default width, height, and quality?
May 24, 2011
Hey nice tutorial , i wanted to know how can i use this script in wordpress?? with the post-thumbnail feature?
May 28, 2011 • @eshan_kanade
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.
June 3, 2011
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
June 4, 2011
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.
June 3, 2011
TimThumb is an image resizing script. There is only 1 file
October 26, 2011
Hi,
I hv been experiencing issue with cropping of the photos.
if you have a look at http://www.tudomudou.com/mashlife/
the images in the sidebar are all cropped in unequal proportion.
Please let me know how can this be fixed?
June 5, 2011 • @ajaykumarmeher
Excuse me, I would like to use in windows iis in timthumb.php
zh-bs.com can not use
June 7, 2011 • @no user
I am not aware of ay problems with Windows server. AFAIK it should work fine. Do you get any errors?
June 7, 2011
http://zh-bs.com/....gif&w=160&h=140&zc=1
you look? it can not show pictures, but can generate images in the cache, permissions set up everyone, the picture shows pork on a skewer
Website is zh-bs.com
June 8, 2011 • @no user
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.
June 28, 2011
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
July 4, 2011
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.
July 8, 2011
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/
August 6, 2011 • @thasneen
Hi Ben, I am still waiting to hear your input on this. Thank you!
August 9, 2011 • @thasneen
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.
August 7, 2011 • @thasneen
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?
August 9, 2011
It can deal with any image size. It's up to you how you use it.
August 12, 2011
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
August 10, 2011 • @pixedelic
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.
August 12, 2011
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
August 12, 2011 • @yachtibis
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!
August 15, 2011 • @easymoneysites
Hello there,
same problem here as Ken S and Sammiej
any new about it?
thank you!:)
September 1, 2011
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
October 10, 2011
Hi,
I can't seem to get the thumbnails to show up in my slider in a WP theme called Milan from Siiimple.
I've set the code to allow external sides, tried different permissions, and yet it never loads the images:
http://www.sublimethings.com/beings/?p=351
Would you mind taking a look at the code?
October 15, 2011
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!
October 31, 2011
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!
November 6, 2011
@Bigmath, Hi, try making your folder cache to 777 and thumbs to 777. I hope this works.
November 11, 2011 • @starfallzone
I've got the same exact problem as Kristian. Images are cached, but not not displayed.
http://sawln.org/category/blog-media/
November 11, 2011
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.
November 14, 2011
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
November 20, 2011
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
November 26, 2011
just omit any stuff you don't want to use.
December 9, 2011
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 ^_^
November 26, 2011 • @dreamlore82
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.
December 26, 2011
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?
November 30, 2011 • @sonill
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.
December 9, 2011
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
November 30, 2011
please try the latest version of TimThumb. If you're on Windows then this may have fixed a number of issues.
December 13, 2011
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.
December 5, 2011
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.
December 9, 2011
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.
December 16, 2011
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.
December 24, 2011
OK I used getimagesize to get the size of image and conditionally call TT url or image one.
December 25, 2011
Sounds like a good solution to me
December 26, 2011
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
December 29, 2011
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.
December 30, 2011
i resize from 200x300 to 100x150 is that too large? i got about 1000 thumbnails that way.
January 4, 2012
If it works then it's fine
January 8, 2012
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.
January 8, 2012
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.
January 8, 2012
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/...roupby=&sort=&id=315
Took awhile for me to figure this out, sorry for the confusion.
January 8, 2012
Hi Tommy - this sounds like an issue with WordPress multisite - there's info on how to solve this here: http://www.binarymoon.co.uk/...10/timthumb-wordpress-mu/
January 10, 2012
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.
January 8, 2012
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.
January 12, 2012
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">.
January 12, 2012
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.
January 12, 2012
Trying one last time with the code:
<a href="" rel="shadowbox;width=930;"><img src="/timthumb.php?src=&w=206&h=104&zc=1">January 12, 2012
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
January 16, 2012
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?
January 24, 2012
Hey Ben,
Loving timthumb, but I find it to be very slow. I can't seem to find anyone else with this issue, so I must be doing something wrong, here is my site
http://www.mav-media.com/maverick-creative/work/
these images take forever.
thoughts / help appreciated!
thanks
February 11, 2012
It's loading ok for me...?
February 20, 2012
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/...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
February 12, 2012 • @nivovas
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
February 17, 2012
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?
February 17, 2012
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.
February 17, 2012
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.
February 20, 2012
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"
March 5, 2012 • @kisaro
Hi Justin,
Awesome script have nice options resize cache crop... but why script don't have rotate option for nn degrees?
Regards
March 12, 2012
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
March 16, 2012
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.
March 16, 2012
Humm, I see what you mean, I have to find another solution with my hosting.
Thanks a lot for your quick response!!!
March 16, 2012
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/...ld/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!
March 22, 2012
I don't know how you have your theme setup but when I tried - just removing the .. from the src parameter worked fine.
March 22, 2012
The link got truncated when the comment posted. Let me try it this way:
http://www.scentofthemissing.com/...ld/timthumb.php?src=../images/th-trailer.jpg&h=62&w=62&zc=1&q=100
March 24, 2012
OK, putting a PRE tag around it didn't help. Let me break it into three lines. Pretend these line breaks aren't there:
http://www.scentofthemissing.com/wp-content/themes/
ColdStone-old/timthumb.php?src=../images/th-
trailer.jpg&h=62&w=62&zc=1&q=100
March 24, 2012
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 (200x200) is larger than the set dimensions (100X100), it just centers on the image and takes that center 100x100 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
March 25, 2012
Take a look at the zc parameter - that may help
March 28, 2012
Hi,
I've used timthumb a lot of times, but this time its not showing the images.
Its just showing a link, and after trying to open that link I get this error:
Could not get a lock for writing.
You can see that in the following link: http://www.everify.com/...038;h=150&w=150&zc=1
My page that I get the above link is:
http://www.everify.com/resources/?p=1309
Its the testing link there under the red written "testing"
I'd be glad if you gave me a small hint.
March 26, 2012
Hi,
my problem is:
A TimThumb error has occured
The following error(s) occured:
Could not find the internal image you specified.
Query String : src=http://www.stoneitaliana.com/wordpress/wp-content/uploads/2012/03/aaa.png&h=&w=662&zc=1
TimThumb version : 2.8.10
Can you help me?
Thanks a lot.
March 27, 2012
Well, I was hoping there was a way that the script could append a relative URL and make it an absolute URL, but I don't know how to program that. So I just manually made the change on all the posts on my site. Fortunately, there weren't that many. TimThumb is working great again!
March 28, 2012
I have installed timthumb on a child theme based on TwentyEleven but I'm getting no thumbnail. My callup has a "alt name" in it and the alt name is showing up for each of three test thumbnails, but the images aren't coming up.
I looked at my source code and it's looking for a scripts folder in TwentyEleven while it's trying to call up an image from my child theme. No wonder nothing is working! But, my scripts folder is in the child theme where it belongs! I double checked my site and it's properly using the child theme.
My template code is this: <img src="/scripts/timthumb.php?src=ID, "thumb", $single = true); ?>&h=150&w=150&zc=1" alt="" width="150" height="150"/>
My source says this:
Note that it's looking for the timthumb script in TwentyEleven.
Apparently, the issue is that I need my 'template_directory' to go to my child theme, not TwentyEleven. What do I need to do? How do I achieve this? Is this a timthumb issue? It seems that 'template_directory' should go to my child theme.
April 7, 2012
It looks like you must be stripping out anything that appears to be a URL or something, so my examples didn't get displayed properly above.
Anyway, my template PHP is calling up the 'template_directory' to look for the timthumb script, but my source code shows that it's looking for it in the parent theme, not the child theme. I have no script in the parent theme (properly so) but I have it in my child theme with CHMODs set appropriately. And my child theme is activated.
April 7, 2012