TimThumb doesn’t work with WordPress Multisite
I’ve created a WordPress Multisite usin the sub-folder method.
- site_name.com
- site_name.com/es
The theme has the TimThumb script for image resizing.
Then I found a problem. My second site (es) was not loading any images.
- site_name.com/wp-content/uploads/2011/09/05/image.jpg
- site_name.com/wp-content/es/files/2011/09/05/image.jpg
WordPress builds a cool link for the “es” site but it doesn’t work if you use it with TimThumb.
If you open your FTP client you would find the file under:
/wp-content/blogs.dir/BLOG_ID/files/2011/09/05/image.jpg
That’s the path you will have to use with TimThumb.
Something like this:
function get_image_path ($post_id = null) {
if ($post_id == null) {
global $post;
$post_id = $post->ID;
}
$theImageSrc = get_post_meta($post_id, 'Image', 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;
}
if ($post_id == null) {
global $post;
$post_id = $post->ID;
}
$theImageSrc = get_post_meta($post_id, 'Image', 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;
}
Related PostsIf you liked TimThumb doesn’t work with WordPress Multisite; the posts below might interest you too:
|




April 12, 2012
14:48
Can you advise on how to modified the code to get it work on a WP Multisite that’s using the sub-domain method?
Thanks.
April 12, 2012
15:40
Have you tried the code above ?
Have you tried to use the latest version ?
http://timthumb.googlecode.com/svn/trunk/timthumb.php
Kind regards