0

画像を表示するためにSmartImageResizerを使用しています。これは、単一サイトのWPで正常に機能します。ただし、WPMUでは機能しません。

サブドメインを使用してWPMUでSmartImageResizerを使用した人はいますか?

4

1 に答える 1

0

さて、image.phpファイルをハッキングして修正しました。

問題は、SmartImageResizerがDOCUMENT_ROOTベースアップロードフォルダーの定義に使用することでした。ワードプレスのアップロードフォルダーは含まれていません(WPとWPMUの両方)。そこで、これを修正するために、image.phpファイルにいくつかのコードを追加/変更しました。

// 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の両方で機能します。

于 2010-09-21T20:38:08.057 に答える