ferenznetworks / timthumb

Automatically exported from code.google.com/p/timthumb
0 stars 0 forks source link

won't work the first time #34

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I use timthumb just like it is, insert an image tag into my wordpress theme 
like this:
<img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb_109.php?
zc=1&w=610&h=280&src=<?php postimage_special(610,280); ?>">

The problem is: it only works the second time. Obviously, the first call to the 
page will generate the 
thumbnail, but not actually display it. The subsequent calls (or a refresh) 
show the file just fine.

So ... how do I fix this?

cache folder has 777, php file has 777, I have no idea what it could be.

pls help

Original issue reported on code.google.com by mores.da...@gmail.com on 30 Jun 2009 at 7:20

GoogleCodeExporter commented 8 years ago
Could it have something do with line number 297:
gmdate( 'D, d M Y H:i:s', filemtime( $cache_file ) );

and that the second interval is too large to do a comparison? So the first time 
an image is viewed, it will most 
probably be generated within a milisecond and the viewer won't see it.

This is a problem for me since I do not want to go back into my blog#s archive 
and load EVERY image just to get 
a thumbnail. Isn't there a more precise timing method? Miliseconds? Swatch 
time? I dunno :)

Original comment by mores.da...@gmail.com on 30 Jun 2009 at 7:49

GoogleCodeExporter commented 8 years ago
Well as it is I can't use this tool. It offers so many options, especially the 
zoomcrop is what I really want, but only 
the second time around. 

Are there any other, similar tools out there?

Original comment by mores.da...@gmail.com on 13 Jul 2009 at 5:11

GoogleCodeExporter commented 8 years ago
found this:
http://joedesigns.com/v22/index.php?page=scripts_widgets&id=67

Works for me, even thought the zoomcrop is more of a hack on my part and I'm 
certain it's faulty. But it works 
for the size I need it in, so there you go :)

Original comment by mores.da...@gmail.com on 18 Jul 2009 at 9:32

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I am also experiencing this issue, 6.5 months later.

My user and docroot directory's permissions were set to 750. My script was 
buried deep in (my) custom 
WordPress theme's directory, but to remove some failure points I made a new 
copy of it at 
~/httpdocs/uploads. (httpdocs is my docroot, I have no control on that).

I then ensured the following directories were set with permissions of 777:
~ (was 755)
~/httpdocs (was 750)
~/httpdocs/uploads (777 since I made it)
~/httpdocs/uploads/cache (777 since I made it)

I still experience the same issue. For security reasons, I've since set my 
permissions back to where they were.

This issue is old but apparently unresolved. I would really like to use this 
script but need resolution.

Site is running on a GoDaddy virtual server, Linux kernel 2.6.18, PHP 5.2.6, GD 
2.0.34.

**IF** this helps, I do not have this issue at all if I do not create/use a 
cache folder (but you can imagine the 
nightmare that will come with doing this).

Original comment by justin.g...@gmail.com on 2 Feb 2010 at 9:03

GoogleCodeExporter commented 8 years ago
Any updates?  I have a similar issue.  If I create 3 thumbs it works fine but 
when I 
try a 4th..no luck.  Says file not found but I can navigate to the url without 
an 
issue.  File size is small too.

Original comment by joshd...@gmail.com on 5 Feb 2010 at 1:54

GoogleCodeExporter commented 8 years ago
I believe I've resolved this issue.

When the cache file is first generated, some PHP installations still have the 
file size cached when returning the 
header.

I had to manually telnet to port 80 and request my images to see this 
happening. Timthumb was returning a 
content-length of 0 on the first load, but still outputting the cache file 
data. Most servers see this as "Oh, this 
is no content" and promptly close the connection before anything can be 
returned.

To fix it, do this:

1 - find this block of text
        $fileSize = filesize($cache_file);

2 - add this function BEFORE the block:
    clearstatcache();

I hope this fix gets put in the next release ASAP.

Original comment by justin.g...@gmail.com on 6 Feb 2010 at 12:47

GoogleCodeExporter commented 8 years ago
Hi Justin, thanks for the code, I have implemented your suggestion - it makes 
total
sense. Hopefully that has resolved the issue.

Original comment by BinaryMoon on 26 Apr 2010 at 8:20