Tim thumb script is working fine, My issue is with absolute path and relative path.

when i give relative path, i get the output. but when i use the absolute path, i am getting 403 forbidden error.

I would like to use absolute path. Pleas advise




I always do this with Timthumb:

// this is the absolute path
$url = 'http://crizaze.com/wp-content/themes/joorang/wp-content/uploads/2011/01/ami166a-e1295733091216.jpg';

// convert it into relative path
$url = str_replace(get_bloginfo('url'), '', $url);

// get the image url, resized by timthumb
$timthumb_url = get_stylesheet_directory_uri() . "/timthumb.php?src=$url&w=80&h=80";

I would like to know what absolute path you are using, but this should work. Of course you may have to do some tweaking to dynamically change the image.

$absolute = get_home_url.'/wp-content/uploads/2011/01/ami166a-e1295733091216.jpg';

$timThumb = http://crizaze.com/wp-content/themes/joorang/timthumb.php?src='.$absolute.'&h=80&w=80&zc=1


I took out your foreach loop because get_post_meta will only return one the first value if set to true. I have not tested this out

//removed function

Also take a look at Using TimThumb Part 2: External Websites. Make sure your cache/ and temp/ folders are set to 755 and add your website 'crizaze.com' to the $allowedSites array in timthumb.php. I believe this is your problem for absolute urls.

  • "get_post_meta will only return one the first value if set to true" - true, but in this case, it looks like the meta value itself is a serialized array, so it does need to be looped through. Feb 1 '11 at 0:37
  • Thanks goldenapples, I did not know that could be done. In that case ignore my function.
    – Evan Yeung
    Feb 1 '11 at 1:07

If http://crizaze.com/wp-content/themes/joorang/timthumb.php?src=/wp-content/uploads/2011/01/ami166a-e1295733091216.jpg&h=80&w=80&zc=1 is your absolute path, then it doesn't work because the path is incorrect. that path reads like this:


when it needs to be



You can use the wp_upload_dir() function to get the path info to your uploads directory. Try something like this:

// Where $data represents the fully qualified url, 
// find $relative relative path
$upload_dir = wp_upload_dir();
$relative = str_replace( 

I modified the script as below and it worked... Thank you so much for the help.

enter code here

function portfolio_small_single($id){ $meta_value = get_post_meta($id, '_port_data', true);

$return = '<ul id="small_thumb_lists">' . "\n";
if( $meta_value != ""){
    foreach( $meta_value as $i => $data ){
        if(!empty($data)) {
        $return .= '<li><a href="'.$data.'">' . "\n";
                $data = str_replace("http://crizaze.com", "", $data);
                $return .= '<img src="' . get_bloginfo('template_url') . '/timthumb.php?src=' . $data . '&amp;h=80&amp;w=80&amp;zc=1" alt="" />';}
                $return .= '<img src="' . get_bloginfo('template_url') . '/images/vid80.jpg" width="80" height="80" alt="" />';
        $return .= '</a></li>' . "\n";
$return .= '</ul>' . "\n";

return $return;


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy