tkale86 / timthumb

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

Base folder config option #292

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Sometimes timthumb is used within software that is not directly located under 
the root but still wants to use a relative src location.

For this I'd like to request a config option for base folder.
This option should be used when searching for the file in code like
if(file_exists ($this->docRoot . '/' . $src))
Obviously the value for base folder should be in between docRoot and src.

Original issue reported on code.google.com by harm.kra...@gmail.com on 21 Nov 2011 at 9:37

GoogleCodeExporter commented 9 years ago
Actually, it's not a base_folder config option that is needed, but a doc_root 
option. This would require very little change to the code, just add two lines 
to calcDocRoot, and I have a very good use case:

The current version of timthumb.php doesn't work for user_dir in Apache. The 
reason is that DOCUMENT_ROOT is (typically) /var/www, but the user home 
directory is (typically) /home/username/public_html. Since these have no common 
part, the images locate somewhere below /home/username/public_html will never 
be found by timthumb. 

Thx for listening.

Original comment by hansfn@gmail.com on 23 Nov 2011 at 10:24

GoogleCodeExporter commented 9 years ago
what are the two lines you would add to calcDocRoot?

Original comment by BinaryMoon on 24 Nov 2011 at 8:52

GoogleCodeExporter commented 9 years ago
I can write a proper patch later tonight (with those two lines ++).

PS! Why didn't I get an email change notification? That should be automatic for 
people that have commented and I thought it was ...

Original comment by hansfn@gmail.com on 24 Nov 2011 at 8:22

GoogleCodeExporter commented 9 years ago
PS! Issue 271 is strongly connected to this issue. They aren't 100% identical, 
but a solution here could fix the problems in issue 271 too.

Original comment by hansfn@gmail.com on 24 Nov 2011 at 8:30

GoogleCodeExporter commented 9 years ago
Patch against rev 190 attached. It does nothing unless you define 
LOCAL_FILE_BASE_DIRECTORY in timthumb-config.php. 

In the use case I described above, the needed line in timthumb-config.php would 
be:

define ('LOCAL_FILE_BASE_DIRECTORY', '/home/username/public_html');

Original comment by hansfn@gmail.com on 24 Nov 2011 at 9:06

Attachments:

GoogleCodeExporter commented 9 years ago
@BinaryMoon: Did you miss my patch above? It's trivial so it shouldn't be hard 
to decide whether you accept it or not.

Original comment by hansfn@gmail.com on 3 Dec 2011 at 6:49

GoogleCodeExporter commented 9 years ago
I didn't miss it - I just don't check the issues every day.

I have implemented a much simpler version of what you are suggesting. Same 
theory, but only 3 lines of code added to calcDocRoot method.

Hansfn - no idea why you didn't get an email notification I'm afraid. I would 
assume it's automatic too.

Original comment by BinaryMoon on 5 Dec 2011 at 10:24

GoogleCodeExporter commented 9 years ago
Thx, Binarymoon. Very much appreciated. 

PS! The reason I didn't change calcDocRoot was in case you used it for 
something else. Making the change only in getLocalImagePath I knew it would 
have minimal impact.

Original comment by hansfn@gmail.com on 6 Dec 2011 at 7:44