0

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.

2
  • 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. Commented Jul 25, 2011 at 19:03
  • Please add your solution as an answer, that would be more in line with site's mechanics. TIA
    – Rarst
    Commented Aug 23, 2011 at 11:00

1 Answer 1

2

You need to use the global $current_blog instead.

$GLOBALS['current_blog']->blog_id

will return the correct id.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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