[Resolved] Using get_blog_id_from_url as a workaround for timthumb issue
I have an installation which uses wpmu sitewide tags plugin to gather all subsite blogs into the main tags blog and then display these on the home page (of the main tags blog).
I also use the wootumblog plugin to distinguish each post custom taxonomy and then display either a default image (for audio, quote, link etc..) or grab the image from a post and then display – suitably scaled by timthumb to fit the display on my main tags blog homepage.
You can see the home page on the following link – http://skiddnet.com
I stumbled across the usual problems with such an approach, and have several functions constructed in functions.php;
– catch_that_image() – which grabs the first image in a post
– dyn_getimagepath($img_src) – which converts the relative path of images in a multisite installation to the absolute path needed by the timthumb script
The problem with the ‘getimagepath’ function is that it returns a blog_id = 1 every time. This seems to be caused by the fact that since the script is running on the main tags blog (i.e. with a blog_id of 1), therefore the global $blog_id variable reflects the current blog.
I came across the timthumb workaround by andrea_r – http://wpmututorials.com/hacks/timthumb-workaround/ – but could not make it work in my configuration.
All I really need is a simple way of determining what the original blog_id is for a given url. So then I discovered the multisite function, get_blog_id_from_url, which andrea uses in her workaround, but I’m unclear how to use from studying the codex.
What I believe I need to do is to break the URL into domain and path and then use get_blog_id_from_url, but I am still trying to figure out how to do so, or find any examples.
Can anyone help?
To save any unnecessary confusion, this is the same question that I posted on wordpress.stackexchange.com
get_blog_id_from_urlseems to be exactly the function I need, but I cannot figure out why it doesn’t just use ‘post_id’ as the argument rather than domain/path. If anyone has used it before and has an example of the arguments required, then I’d be most grateful. I cannot as yet find anything more detailed than the information already contained in wp-includes/ms-functions.php
I have found 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:
I couldn’t find any other solutions, so hopefully this will help someone else.
Wow thank you for the solution, was just wrangling with this myself.
kick butt site ur building there!
Thanks very much. if there’s anything you see on my site which would help, then you’re welcome to peek under the covers and I’m happy to share the code.
Wow, thank you for the offer.
If you want to look at an alternative to timthumb, check this out. I have been using it for a very long time now and absolutely love it.
- The topic ‘[Resolved] Using get_blog_id_from_url as a workaround for timthumb issue’ is closed to new replies.