WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Using get_blog_id_from_url as a workaround for timthumb issue (6 posts)

  1. DoctorDR
    Member
    Posted 2 years ago #

    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?

  2. DoctorDR
    Member
    Posted 2 years ago #

    To save any unnecessary confusion, this is the same question that I posted on wordpress.stackexchange.com

    http://wordpress.stackexchange.com/questions/24000/how-to-get-blog-id-of-an-mu-site-when-running-a-custom-function-on-the-parent-sit

    The get_blog_id_from_url seems 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

  3. DoctorDR
    Member
    Posted 2 years ago #

    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:

    http://pastebin.com/XbhMSK2v

    I couldn't find any other solutions, so hopefully this will help someone else.

  4. Anointed
    Member
    Posted 2 years ago #

    Wow thank you for the solution, was just wrangling with this myself.

    b.t.w.
    kick butt site ur building there!

  5. DoctorDR
    Member
    Posted 2 years ago #

    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.

  6. Anointed
    Member
    Posted 2 years ago #

    @DoctorDr
    Wow, thank you for the offer.

    btw
    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.

    http://core.trac.wordpress.org/ticket/15311#comment:13

Topic Closed

This topic has been closed to new replies.

About this Topic