WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] WP-Creativix, need help implementing fix, timthumb call for image in WP 3.0 (2 posts)

  1. mbeasi
    Member
    Posted 4 years ago #

    Hello! So, now that the multi-site functionality of WPMU has been merged with WP 3.0, I've tried to use WP-Creativix on a new WP-created subdomain. Unfortunately, now that I've done that, I'm having the problem with timthumb and file paths well-documented in posts like these.

    Can anyone help? As you can see by looking at this test install, the only difference between it and the new install is that timthumb can't find the correct file paths in order to create thumbnails when the blog is *not* the primary blog.

    I attempted to implement the fixes suggested by people in the WPMU forums, but I'm just not a strong enough coder to figure out how to make those work with this theme.

    Help??

    Here was a suggested fix sent to me by a friend, which did not work, but perhaps provides more info:

    First, in the wp-creativix theme folder, paste the following code (in php tags, of course) after the call to get_header(); at the top of index.php:

    function get_image_path($src) {
    global $blog_id;
    if(isset($blog_id) && $blog_id > 0) {
    $imageParts = explode('/files/' . $src);
    if(isset($imageParts[1])) {
    $src = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
    }
    }

    return $src;
    }

    Then in index.php, where it references timthumb.php and then does "echo $value[0];", replace it with "echo get_image_path($value[0]);" (When I downloaded the unaltered theme, this code was on line 30.)

    Any help greatly appreciated.

  2. mbeasi
    Member
    Posted 4 years ago #

    Success! Solution: This was achieved with a combination of Binary Moon's fix (http://www.binarymoon.co.uk/2009/10/timthumb-wordpress-mu/), along with the stuff quoted above from my friend, and one tip from a guy in the Binary Moon thread which gave me the final piece of the puzzle.

    If anyone else is using WP 3.0 with WP-Creativix on a subdomain, put this in in functions.php (in php tags):

    function get_image_path ($post_id = null) {
    if ($post_id == null) {
    global $post;
    $post_id = $post->ID;
    }
    $theImageSrc = get_post_meta($post_id, 'Image', true);
    global $blog_id;
    if (isset($blog_id) && $blog_id > 0) {
    $imageParts = explode('/files/', $theImageSrc);
    if (isset($imageParts[1])) {
    $theImageSrc = 'wp-content/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
    }
    }
    return $theImageSrc;
    }

    And then in the Main Index Template, where timthumb calls for the file, change "echo $values[0]" to "echo get_image_path ($values[0])"

Topic Closed

This topic has been closed to new replies.

About this Topic