Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Simple enough question, but one which is proving difficult to find a solution to.

Quick preamble - the situation this is addressing is a MU network using sitewide tags plugin which pulls all network posts to the main site's home page, then timthumb is used to scale the images of each post which are retrieved using a custom get_first_image function. The usual problem occurs whereby the image retrieved by the get function has a relative path rather than the absolute URL needed by timthumb, hence I run it through a filter to reconstruct the absolute URL. All works fine except blog_id always equals '1' for every post. This is clearly because the blog_id on which the function runs upon (i.e. the main parent blog) is '1' and therefore I need to determine the blog_id for the original post and use this when reconstructing the absolute URL.

Can anyone help?

I have tried using the wordpress function, get_blog_id_from_url but there's very little guidance or examples on its use. I have also tried variations of $current_site->blog_id and $GLOBALS['current_site']->blog_id, but I have been so far unable to return any blog_id value except 1.

share|improve this question
    
Sorted. I've gone with this as a solution for my current configuration, so for anyone else looking to run timthumb on a parent multisite blog, which has been populated by sitewide tags plugin, here's the code that transforms a relative image path into an absolute one: wordpress.org/support/topic/… I couldn't find any other solutions, so hopefully this will help someone else. –  Steve Davies Jul 25 '11 at 19:03
    
Please add your solution as an answer, that would be more in line with site's mechanics. TIA –  Rarst Aug 23 '11 at 11:00
add comment

1 Answer 1

You need to use the global $current_blog instead.

$GLOBALS['current_blog']->blog_id

will return the correct id.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.