I am trying to get timthumb working with wpmu. Having followed the directions on his site, I am able to successfully grab a 'thumb' custom field and have it show up in my post using the following code:
function get_image_path ($post_id = null) {
if ($post_id == null) {
global $post;
$post_id = $post->ID;
}
$theImageSrc = get_post_meta($post_id, 'thumb', true);
global $blog_id;
if (isset($blog_id) && $blog_id > 0) {
$imageParts = explode('/files/', $theImageSrc);
if (isset($imageParts[1])) {
$theImageSrc = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
}
}
return $theImageSrc;
}
What I would like to do is have a function that will search the post for the first image, and then return that image url 'properly formatted for wpmu with the 'blogs.dir/#/files' within the url so that timthumb can function.
Here is the function that I am using currently which works with non-mu sites, but does not work with wpmu.
/*this function allows users to use the first image in their post as their thumbnail*/
function catch_that_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];
return $first_img;
}
Obviously that function does not return the wpmu image url that is needed, as the blogs.dir/blogid# is missing from the url.
Could someone please help me with this?