- Timthumb.php, WP Multisite & the images “url path” about *
Dear John,
I´m evaluating your great theme in order to implement (OpenHouse) into an WP Multisite inviroment. I had read all post and comments about Timthumb.php & WP MU issues.
After check and fulfill all your primary recomendations (latest PHP version, GD enable, directory/files permisions, latest timthumb.php version, image size, etc.), and having confirmed TimThumb is working fine, I found the problem of most of customers is about the way to get the “url path” of image in order to pass it to Timthumb.
For this reason is that I would like to share with you a piece of code I found and think it can be the final solution to this our problem. It consist in create a an extra function to “calculate” where is really saved the images we want to pass to Timthumb. It´ll be an universal solution, not only for MU enviroment, but also for subdirectory issue too.
I thanks to Damian, the author: http://www.masquewordpress.com/timthumb-php-y-wordpress-mu/#
Function code:
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;
and here the way to invoke that function:
<? $imagen=get_image_path ( $post->ID); ?>
<img src="timthumb.php?src=<? echo $imagen; ?>" alt="" />
I wish and hope you´ll take into account my proposal in order to modify the way the theme to call Timthumb script. Nobody better than you know where exactly changes should be carried out (sidebar-right.php, single-listing.php, slider.php, etc.)
Please be assured the entire community of customers will appreciate your effort to resolve once and for all this old problem. Thanks in advance and have a nice day, Sergio.



5103 Purchases
1695 Comments