Enable thumbnail support in SimplePress and a multi-site WordPress

I was looking forward to use the thumbnail and gallery options of the SimplePress theme from ElegantThemes, only to find empty thumbnails when I tried it out.

A bit of research put me on the way to a solution via ‘How to make TimThumb work with WordPress mu‘. The culprit was the difference between virtual paths and physical paths in a multi-site installation of WordPress (WordPress mu is now available by default in WordPress 3.0).

Between this post and some of the comments, I was able to get thumbnails to work.

1- Add a new function ‘get_image_path’ to ‘SimplePress/epanel/custom_functions.php’, at line 149 :

[code]

/* Get virtual path from post ID and full path – enable for multiple sites setup */
function get_image_path ($post_id = null, $theImageSrc) {
if ($post_id == null) {
global $post;
$post_id = $post->ID;
}

global $blog_id, $current_site;

if (isset($blog_id) && $blog_id > 0) {
$imageParts = explode(‘/files/’, $theImageSrc);
if (isset($imageParts[1])) {
$theImageSrc = ‘http://’ . $current_site->domain . $current_site->path . ‘wp-content/blogs.dir/’ . $blog_id . ‘/files/’ . $imageParts[1];
}
}
return $theImageSrc;
}

[/code]

2- In the same file, add these lines at the end of ‘get_thumbnails’  (before ‘if ($fullpath)’ )

[code]

/* Replace virtual path by full path – enable for multiple sites setup */
$thumb_array[‘thumb’] = get_image_path($post->ID, $thumb_array[‘thumb’]);

if ($fullpath) $thumb_array[‘fullpath’] = $thumb_array[‘thumb’];

[/code]

This should make the thumbnails available assuming you are using images loaded to the site using the Media library.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: