views:

35

answers:

1

I'm using Smart Image Resizer for dispalying images. This works fine on single site WP. But it does not work for WPMU.

Has anyone used Smart Image Resizer in WPMU using subdomains?

Update
I've found the solution. It's added below.

A: 

Ok, so I have kind of fixed it by hacking image.php file.

The problem was that Smart Image Resizer uses DOCUMENT_ROOT to define base upload folder. It does not include wordpress upload folders (for both WP and WPMU). So I added / changed some code in image.php file to fix this.

// Let's include Wordpress libraries
// We assume this file WILL be located in root folder
require_once($_SERVER['DOCUMENT_ROOT'].'/wp-blog-header.php');

// This must be included just after the above include. Otherwise we can get a 404 Not Found error in WPMU 
header('HTTP/1.1 200 OK');    // ****** Wordpress hack ********

//Define upload dir for Wordpress
$upload_dir = wp_upload_dir();
define('WP_IMAGE_UPLOAD_DIR', str_replace("\\","/",$upload_dir['basedir']));
define('WP_IMAGE_UPLOAD_URL', str_replace("\\","/",$upload_dir['baseurl']));

// Replace the original code to remove base URL (and upload path)
$image = str_replace(WP_IMAGE_UPLOAD_URL,'',$_GET['image']);

// Then I replace the old docRoot with the new upload path,
// and kept the stripping of possible trailing slash off the document root
$docRoot    = preg_replace('/\/$/', '', WP_IMAGE_UPLOAD_DIR);

// Then I change the code so it uses correct upload path.
if (!file_exists(WP_IMAGE_UPLOAD_DIR . $image))
{
    header('HTTP/1.1 404 Not Found');
    echo 'Error: image does not exist: ' . WP_IMAGE_UPLOAD_DIR . $image;
    exit();
}

Now it works for both WP and WPMU.

If this solution works for you, please upvote so that I can see how many this was usefull for (if u r registered).

IF you have a better solution, plese comment :)

Steven