有人在子域网站上使用Smart Image Resizer吗? [英] Has anyone used Smart Image Resizer on subdomain sites?

查看:93
本文介绍了有人在子域网站上使用Smart Image Resizer吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用智能图像缩放器来使图像变色.这在单站点WP上运行良好.但这不适用于WPMU.

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

有人使用子域在WPMU中使用Smart Image Resizer吗?

Has anyone used Smart Image Resizer in WPMU using subdomains?

推荐答案

好,所以我已经通过入侵image.php文件对其进行了修复.

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

问题是Smart Image Resizer使用DOCUMENT_ROOT定义基本上载文件夹.它不包括wordpress上传文件夹(适用于WP和WPMU).因此,我在image.php文件中添加/更改了一些代码来解决此问题.

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();
}

现在它同时适用于WP和WPMU.

Now it works for both WP and WPMU.

这篇关于有人在子域网站上使用Smart Image Resizer吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆