khashnan / timthumb

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

Fetching of local URLs over HTTP should be an option (patch attached) #342

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When TimThumb encounters a URL with the same hostname as itself, it will (quite 
reasonably) try to fetch that file from disk rather than using an HTTP request.

However, URLs often don't have a direct mapping to a file on disk. On a 
multi-site install of WordPress, for example, the URL /files/2012/02/foo.jpg 
might actually map to wp-content/blogs.dir/1/uploads/2012/02/foo.jpg on disk.

A quick workaround for this is to make this a setting. I personally don't care 
about saving the HTTP requests, since TimThumb will cache my thumbs; however, I 
do use quite a few redirected URLs, which break with the default TimThumb 
settings.

The attached patch does just that: it creates a setting called FETCH_LOCAL_URLs 
that, if true, will ensure that local URLs are always fetched over HTTP. It 
would be great if this could be included in the next release of TimThumb!

Original issue reported on code.google.com by r...@bigfish.co.uk on 19 Feb 2012 at 8:15

Attachments:

GoogleCodeExporter commented 8 years ago
I've made the default setting false, by the way, in order to not change 
existing functionality, but I really think this setting should be on by 
default. Saving one HTTP request for the original image is such a small saving, 
not at all worth the cost of completely breaking when redirected URLs are 
encountered.

Original comment by r...@bigfish.co.uk on 19 Feb 2012 at 8:16

GoogleCodeExporter commented 8 years ago
Sorry, just realised I didn't patch against latest trunk; here's an SVN patch 
against that.

Original comment by r...@bigfish.co.uk on 19 Feb 2012 at 8:22

Attachments:

GoogleCodeExporter commented 8 years ago
thanks for the suggestion Rob - added

Original comment by BinaryMoon on 20 Feb 2012 at 12:51

GoogleCodeExporter commented 8 years ago
This is the solution I need too! 
I'm adding the patch and I get an error for line 'if(! 
defined('FILE_CACHE_ENABLED') )         define ('FILE_CACHE_ENABLED', TRUE);                    // 
Should we store resized/modified images on disk to speed things up?'

Am I doing something wrong?

Original comment by katerina...@gmail.com on 19 Jan 2013 at 3:42

GoogleCodeExporter commented 8 years ago
This change was included here:

https://code.google.com/p/timthumb/source/detail?r=211

But seems to have been reverted here:

https://code.google.com/p/timthumb/source/detail?r=214

Is there any reason for that? It's a pretty important function for us, since we 
have lots of WordPress multisite sites.

Original comment by pow...@gmail.com on 27 Mar 2013 at 3:23