开发者

Has anyone used Smart Image Resizer on subdomain sites?

I'm using Smart Image Resizer for dispalying images. This wor开发者_StackOverflow中文版ks fine on single site WP. But it does not work for WPMU.

Has anyone used Smart Image Resizer in WPMU using subdomains?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜