Revision: 34834
Updated Code
at February 14, 2011 05:48 by krike
Updated Code
/* WORDPRESS MU TIMTHUMB FIX This function will return the correct url for the timthumb php script (wordpress 3.0 or higher required!) Usage: just call the function in your theme with the post id as parameter, it will return a value so store this into a variable (must be inside the wordpress loop to work) The function: $thumb = get_timthumb_thumbnail($post->ID); */ function get_timthumb_thumbnail($post_id = null) { global $blog_id; //we can access it, so why not use it? $is_mu = WP_ALLOW_MULTISITE; //if is true it means it's a wordpress MU site and we'll have to do some work if($is_mu == true): $thumbnail_id=get_the_post_thumbnail($post_id); preg_match ('/src="(.*)" class/',$thumbnail_id,$link); $imageParts = explode('files/', $link[1]); if (!empty($imageParts[1])): //check if the image is in the blog directory if(@getimagesize('./wp-content/blogs.dir/' . $blog_id . '/files/' . $imageParts[1])): $thumbnail = 'http://'.$_SERVER['HTTP_HOST'].'/wp-content/blogs.dir/' . $blog_id . '/files/' . $imageParts[1]; endif; //check if the image is in the main uploads directory (you never know) if(@getimagesize('./wp-content/uploads/' . $imageParts[1])): $thumbnail = 'http://'.$_SERVER['HTTP_HOST'].'/wp-content/uploads/' . $imageParts[1]; endif; else: $imageParts = explode('uploads/', $link[1]); if(@getimagesize('./wp-content/uploads/' . $imageParts[1])): $thumbnail = 'http://'.$_SERVER['HTTP_HOST'].'/wp-content/uploads/' . $imageParts[1]; endif; endif; else: $thumbnail_id=get_the_post_thumbnail($post_id); preg_match ('/src="(.*)" class/',$thumbnail_id,$link); $thumbnail = $link[1]; endif; return $thumbnail; }
Revision: 34833
Updated Code
at February 14, 2011 05:47 by krike
Updated Code
/* WORDPRESS MU TIMTHUMB FIX This function will return the correct url for the timthumb php script (wordpress 3.0 or higher required!) Usage: just call the function in your theme with the post id as parameter, it will return a value so store this into a variable (must be inside the wordpress loop to work) The function: $thumb = get_timthumb_thumbnail($post->ID); */ function get_timthumb_thumbnail($post_id = null) { global $blog_id; //we can access it, so why not use it? $is_mu = WP_ALLOW_MULTISITE; //if is true it means it's a wordpress MU site and we'll have to do some work if($is_mu == true): $thumbnail_id=get_the_post_thumbnail($post_id); preg_match ('/src="(.*)" class/',$thumbnail_id,$link); $imageParts = explode('files/', $link[1]); if (!empty($imageParts[1])): //check if the image is in the blog directory if(@getimagesize('./wp-content/blogs.dir/' . $blog_id . '/files/' . $imageParts[1])): $thumbnail = 'http://'.$_SERVER['HTTP_HOST'].'/wp-content/blogs.dir/' . $blog_id . '/files/' . $imageParts[1]; endif; //check if the image is in the main uploads directory (you never know) if(@getimagesize('./wp-content/uploads/' . $imageParts[1])): $thumbnail = 'http://'.$_SERVER['HTTP_HOST'].'/wp-content/uploads/' . $imageParts[1]; endif; else: $imageParts = explode('uploads/', $link[1]); if(@getimagesize('./wp-content/uploads/' . $imageParts[1])): $thumbnail = 'http://'.$_SERVER['HTTP_HOST'].'/wp-content/uploads/' . $imageParts[1]; endif; endif; else: $thumbnail_id=get_the_post_thumbnail($post_id); preg_match ('/src="(.*)" class/',$thumbnail_id,$link); $thumbnail = $link[1]; endif; return $thumbnail; }
Revision: 34832
Updated Code
at February 14, 2011 05:47 by krike
Updated Code
/* WORDPRESS MU TIMTHUMB FIX This function will return the correct url for the timthumb php script (wordpress 3.0 or higher required!) Usage: just call the function in your theme with the post id as parameter, it will return a value so store this into a variable (must be inside the wordpress loop to work) The function: $thumb = get_timthumb_thumbnail($post->ID); */ function get_timthumb_thumbnail($post_id = null) { global $blog_id; //we can access it, so why not use it? $is_mu = WP_ALLOW_MULTISITE; //if is true it means it's a wordpress MU site and we'll have to do some work if($is_mu == true): $thumbnail_id=get_the_post_thumbnail($post_id); preg_match ('/src="(.*)" class/',$thumbnail_id,$link); $imageParts = explode('files/', $link[1]); if (!empty($imageParts[1])): //check if the image is in the blog directory if(@getimagesize('./wp-content/blogs.dir/' . $blog_id . '/files/' . $imageParts[1])): $thumbnail = 'http://'.$_SERVER['HTTP_HOST'].'/wp-content/blogs.dir/' . $blog_id . '/files/' . $imageParts[1]; endif; //check if the image is in the main uploads directory (you never know) if(@getimagesize('./wp-content/uploads/' . $imageParts[1])): $thumbnail = 'http://'.$_SERVER['HTTP_HOST'].'/wp-content/uploads/' . $imageParts[1]; endif; else: $imageParts = explode('uploads/', $link[1]); if(@getimagesize('./wp-content/uploads/' . $imageParts[1])): $thumbnail = 'http://'.$_SERVER['HTTP_HOST'].'/wp-content/uploads/' . $imageParts[1]; endif; endif; else: $thumbnail_id=get_the_post_thumbnail($post_id); preg_match ('/src="(.*)" class/',$thumbnail_id,$link); $thumbnail = $link[1]; endif; return $thumbnail; }
Revision: 34831
Updated Code
at October 30, 2010 07:06 by krike
Updated Code
/* WORDPRESS MU TIMTHUMB FIX This function will return the correct url for the timthumb php script (wordpress 3.0 or higher required!) Usage: just call the function in your theme with the post id as parameter, it will return a value so store this into a variable (must be inside the wordpress loop to work) The function: $thumb = get_timthumb_thumbnail($post->ID); */ function get_timthumb_thumbnail($post_id = null) { global $blog_id; //we can access it, so why not use it? $is_mu = WP_ALLOW_MULTISITE; //if is true it means it's a wordpress MU site and we'll have to do some work if($is_mu == true): $thumbnail_id=get_the_post_thumbnail($post_id); preg_match ('/src="(.*)" class/',$thumbnail_id,$link); $imageParts = explode('files/', $link[1]); if (!empty($imageParts[1])): //check if the image is in the blog directory if(@getimagesize('./wp-content/blogs.dir/' . $blog_id . '/files/' . $imageParts[1])): $thumbnail = 'http://'.$_SERVER['HTTP_HOST'].'/wp-content/blogs.dir/' . $blog_id . '/files/' . $imageParts[1]; endif; //check if the image is in the main uploads directory (you never know) if(@getimagesize('./wp-content/uploads/' . $imageParts[1])): $thumbnail = 'http://'.$_SERVER['HTTP_HOST'].'/wp-content/uploads/' . $imageParts[1]; endif; endif; else: $thumbnail_id=get_the_post_thumbnail($post_id); preg_match ('/src="(.*)" class/',$thumbnail_id,$link); $thumbnail = $link[1]; endif; return $thumbnail; }
Revision: 34830
Updated Code
at October 30, 2010 03:52 by krike
Updated Code
/* WORDPRESS MU TIMTHUMB FIX This function will return the correct url for the timthumb php script (wordpress 3.0 or higher required!) Usage: just call the function in your theme with the post id as parameter, it will return a value so store this into a variable (must be inside the wordpress loop to work) The function: $thumb = get_timthumb_thumbnail($post->ID); */ function get_timthumb_thumbnail($post_id = null) { global $blog_id; //we can access it, so why not use it? $is_mu = WP_ALLOW_MULTISITE; //if is true it means it's a wordpress MU site and we'll have to do some work if($is_mu == true): $thumbnail_id=get_the_post_thumbnail($post_id); preg_match ('/src="(.*)" class/',$thumbnail_id,$link); $imageParts = explode('files/', $link[1]); if (!empty($imageParts[1])): //check if the image is in the blog directory if(@getimagesize('./wp-content/blogs.dir/' . $blog_id . '/files/' . $imageParts[1])): $thumbnail = 'http://'.$_SERVER['HTTP_HOST'].'/wp-content/blogs.dir/' . $blog_id . '/files/' . $imageParts[1]; endif; //check if the image is in the main uploads directory (you never know) if(@getimagesize('./wp-content/uploads/' . $imageParts[1])): $thumbnail = 'http://'.$_SERVER['HTTP_HOST'].'/wp-content/uploads/' . $imageParts[1]; endif; endif; else: //else if false $d_thumb = get_post_meta($post_id, 'default_thumbnail', true); if($d_thumb == true): $thumbnail = get_option('creafolio_default_thumb_img'); else: $thumbnail_id=get_the_post_thumbnail($post_id); preg_match ('/src="(.*)" class/',$thumbnail_id,$link); $thumbnail = $link[1]; endif; endif; return $thumbnail; }
Revision: 34829
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 28, 2010 21:19 by krike
Initial Code
/* WORDPRESS MU TIMTHUMB FIX This function will return the correct url for the timthumb php script (wordpress 3.0 or higher required!) Usage: just call the function in your theme with the post id as parameter, it will return a value so store this into a variable (must be inside the wordpress loop to work) The function: $thumb = get_timthumb_thumbnail($post->ID); */ function get_timthumb_thumbnail($post_id = null) { global $blog_id; //we can access it, so why not use it? $is_mu = WP_ALLOW_MULTISITE; //if is true it means it's a wordpress MU site and we'll have to do some work if($is_mu == true): $thumbnail_id=get_the_post_thumbnail($post_id); preg_match ('/src="(.*)" class/',$thumbnail_id,$link); $imageParts = explode($_SERVER['REQUEST_URI'].'files/', $link[1]); if (!empty($imageParts[1])): //check if the image is in the blog directory if(@getimagesize('./wp-content/blogs.dir/' . $blog_id . '/files/' . $imageParts[1])): $thumbnail = 'http://'.$_SERVER['HTTP_HOST'].'/wp-content/blogs.dir/' . $blog_id . '/files/' . $imageParts[1]; endif; //check if the image is in the main uploads directory (you never know) if(@getimagesize('./wp-content/uploads/' . $imageParts[1])): $thumbnail = 'http://'.$_SERVER['HTTP_HOST'].'/wp-content/uploads/' . $imageParts[1]; endif; endif; else: //else if false $d_thumb = get_post_meta($post_id, 'default_thumbnail', true); if($d_thumb == true): $thumbnail = get_option('creafolio_default_thumb_img'); else: $thumbnail_id=get_the_post_thumbnail($post_id); preg_match ('/src="(.*)" class/',$thumbnail_id,$link); $thumbnail = $link[1]; endif; endif; return $thumbnail; }
Initial URL
Initial Description
This function will return the correct url for the timthumb php script (wordpress 3.0 or higher required!) Usage: just call the function in your theme with the post id as parameter, it will return a value so store this into a variable (must be inside the wordpress loop to work) The function: $thumb = get_timthumb_thumbnail($post->ID); I've tested this successfully on my servers so please let me know if you are having any problem with it.
Initial Title
Wordpress MU timthumb fix
Initial Tags
php, wordpress, script
Initial Language
PHP