Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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


share|improve this question

5 Answers 5

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 ='.$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 '' to the $allowedSites array in timthumb.php. I believe this is your problem for absolute urls.

share|improve this answer
"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. – goldenapples Feb 1 '11 at 0:37
Thanks goldenapples, I did not know that could be done. In that case ignore my function. – imHavoc Feb 1 '11 at 1:07

I always do this with Timthumb:

// this is the absolute path
$url = '';

// 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";
share|improve this answer

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( 
share|improve this answer

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("", "", $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;


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.