Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Absolute path for timthumb script in sitewide tags blog

By: CitizenSlide on Jul 25th, 2011  |  syntax: PHP  |  size: 0.65 KB  |  views: 236  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // transforms a relative image path into an absolute one for running timthumb on a parent WP multisite blog, which has been populated by the sitewide tags plugin
  2.  
  3. function dyn_getimagepath($img_src) {
  4.         if ($post_id == null) {
  5.                 global $post;
  6.                 $post_id = $post->ID;
  7.         }
  8.     global $post_blog_id;
  9.         global $wpdb;
  10.  
  11.    $post_blog_id = get_post_meta($post->ID, 'blogid', true) ;
  12.        
  13.     if (isset($post_blog_id) && $post_blog_id > 0) {
  14.         $imageParts = explode('/files/', $img_src);
  15.         if (isset($imageParts[1])) {
  16.             $img_src = '/wp-content/blogs.dir/' . $post_blog_id . '/files/' . $imageParts[1];
  17.         }
  18.     }
  19.     return $img_src;
  20. }