Advertisement
CitizenSlide

Absolute path for timthumb script in sitewide tags blog

Jul 25th, 2011
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement