/ media / - .htaccess呼び出しに基づいて再生するスクリプトの書き方に関するヘルプ?

magento.stackexchange https://magento.stackexchange.com/questions/3012

質問

私は完全なキャッシュをきれいに実行し、これがすべての下にあることを発見しました /media/ (以下で私が指摘したように、そして後に答えによって正しく観察されたように、それは確かに、 /media/ フォルダ)。残念ながら、これらの画像に依存している過去からの電子メールの分配があり、すべてのサムネイル /キャッシュエントリを再生する方法があるかどうかは興味があります /media/ フォルダ?

したがって、たとえば、この状況では、次のような不足しているファイルが表示されています。

[Mon Apr 15 11:46:01 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/0/image/265x/4df79eab33525d08d6e5fb8d27136e95/T/E/TE0213.jpg
[Mon Apr 15 11:46:01 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/0/image/265x/4df79eab33525d08d6e5fb8d27136e95/F/X/FX0413_1.jpg
[Mon Apr 15 11:46:01 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/0/image/265x/4df79eab33525d08d6e5fb8d27136e95/F/B/FB0413.jpg
[Mon Apr 15 11:46:01 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/0/image/265x/4df79eab33525d08d6e5fb8d27136e95/F/K/FK0413.jpg
[Mon Apr 15 11:46:02 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/0/image/265x/4df79eab33525d08d6e5fb8d27136e95/E/V/EV0413.jpg
[Mon Apr 15 11:46:02 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/0/image/265x/4df79eab33525d08d6e5fb8d27136e95/F/P/FP0413.jpg
[Mon Apr 15 11:46:02 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/0/image/265x/4df79eab33525d08d6e5fb8d27136e95/F/E/FEA0413.jpg
[Mon Apr 15 11:46:03 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/0/image/265x/4df79eab33525d08d6e5fb8d27136e95/F/Z/FZ0413.jpg
[Mon Apr 15 11:46:03 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/0/image/265x/4df79eab33525d08d6e5fb8d27136e95/G/B/GB0413.jpg
[Mon Apr 15 11:46:03 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/0/image/265x/4df79eab33525d08d6e5fb8d27136e95/F/S/FS0413.jpg
[Mon Apr 15 11:46:04 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/0/image/265x/4df79eab33525d08d6e5fb8d27136e95/F/U/FU0413.jpg

たとえば、画像を探すと、以下に存在するオリジナルが表示されます。media/catalog/product/F/U/

したがって、目標は、これらすべてを適切に再生することです。

これにさらに移動すると、画像を見つけられなくなったときにMagentoスクリプトを実行できる必要があることがわかります(特に、これらの画像の多くは、電子メールや他のサイトなどの外部参照によって呼び出されているためには見つかりません。 )。 Apacheのこのようなものを使用して、このスクリプトを呼び出すことを期待しています。

# Inside of .htaccess:
######################
# if the file exists, just send it
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^cache/.*$ - [L]

# if it doesn't exists, rewrite to PHP script
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^cache/.*$ /path/to/script.php?url=$0 [L]
役に立ちましたか?

解決

ファイルは存在しません:/home/username/public_html/domain.tld/media/catalog/product/cache/

画像キャッシュをクリアしました。

メディア/カタログ/製品/f/u/

あなたの元の画像はまだ整っているので、あなたが最初に言ったように、明確な画像キャッシュ機能は明らかに行われませんでした、 obliterates everything under /media/

あなたの大きな問題はそれです あなたのテンプレート 画像を再生するための適切なメディアヘルパーコールを行っていません。不足している画像の問題はどこにありますか?

典型的なヘルパーコールがURLを要求します。URLが存在しない場合、選択したサイズで画像がその場でキャッシュに追加され、URLがHTMLブロックに返されます。

$this->helper('catalog/image')->init($_product, 'small_image')->resize(135)

製品ビューページ画像

<img id="image" src="'.$this->helper('catalog/image')->init($_product, 'image').'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />

製品リスト

<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />

ヘルパーのinit関数は、次の入力を取得することに注意してください。

public function init(Mage_Catalog_Model_Product $product, $attributeName, $imageFile=null)

および処理$ imageFileを次のようにします。

if ($imageFile) {
    $this->setImageFile($imageFile);
} else {
    // add for work original size
$this->_getModel()->setBaseFile($this->getProduct()->getData($this->_getModel()->getDestinationSubdir()));
}

画像文字列で照会されたときにサイズ変更された画像URLをフィードするPOCコード。このサンプルのストア1の場合、指定されたURLによるとYoursはストア0です。

<?php

/*
 * imgurl.php allows you to return image url for imgquery.
 * http://www.example.com/imgurl.php?imgurl=/l/p/lp_5009.jpg
 */

ini_set('memory_limit','256M');

require_once 'app/Mage.php';
umask(0);
Mage::app()->setCurrentStore('1');
$userModel = Mage::getModel('admin/user');
$userModel->setUserId(0);


$product  = "0";
$imgurl   = "";

if (isset($_GET["imgquery"])) {  

    $string = filter_input(INPUT_GET, 'imgquery', FILTER_SANITIZE_URL);

    $imgquery = trim($string);

    $imgurl = Mage::helper('catalog/image')->init($product, 'image', $imgquery)->resize(250, 250);

}

if ($imgurl) {

    echo '<img src="' . $imgurl . '"/>';
}

?>

Get Queryにフィードしてください:

http://www.example.com/imgurl.php?imgquery=/l/p/lp_5009.jpg

キックアウト:

<img src="http://www.example.com/media/catalog/product/cache/1/image/250x250/9df78eab33525d08d6e5fb8d27136e95/l/p/lp_5009.jpg"/>

他のヒント

Magento 1.7.0.2での私の場合のこのエラーは、ズーム画像モジュールの悪いコードです。

Disable it to get the work.

必要に応じて、ファイルが生成されます。電話が必要です Mage::helper('catalog/image)->... これらの画像を作成します。手動でそれを行うか、すべてのリクエストをリダイレクトするスクリプトを書くことができます /media/ このスクリプトに対して、ちょうど時間内に画像を生成します

ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top