Q:

PHP absolute path with timThumb doesn't work

I'm writing a wordpress plugin, and using this script to resize images: Timthumb
This script uses absolute paths, but I can't get it to work for me; I've triple-checked all my paths but still nothing.
Here is my code:
$plugin_dir_name = "my-plugin";

$pathTimThumb = WP_PLUGIN_URL . '/' . $plugin_dir_name . '/timthumb.php';
$pathToUpload = WP_CONTENT_URL.'/uploads/'.$plugin_dir_name;
$hImg = 150;
$wImg = 150;

....

$myImage = '<img class="thumb" src="'.$pathImageThumb.'?src='.$pathToUpload.'/'.$allImages[$i].'&h='.$hImg.'&w='.$wImg.'&zc=1" alt="">';

In firebug I get this URL:
<img alt="" src="http://localhost/mu/wp-content/plugins/my-plugin/timthumb.php?src=http://localhost/mu/wp-content/uploads/my-plugin/car___1/26zhoar5.jpg&amp;h=150&amp;w=150&amp;zc=1" class="thumb">

Where is the mistake?

A:

use this one.
 $my_plugin_url = plugins_url('my-plugin-name/');
    $my_timthumb_url = $my_plugin_url.'timthumb.php?';
    $my_image_url = 'http://localhost/images/image.jpg';
echo '<img alt="" src="'.$my_timthumb_url.'src='.$my_image_url.'&amp;h=150&amp;w=150&amp;zc=1"/>';

things to consider to make timthumb work:

chmod your timthumbs cache folder
do not use external images
check you timthumb version

Cheers,Dave

