我执行了一个完整的缓存清洁,发现这使一切都在下面 /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/

因此,目标是适当地重新生成所有这些。

在此过程中进一步发展,我可以看到我需要能够在未能找到图像的情况下执行洋红色脚本(尤其是因为由于外部参考(例如电子邮件或其他网站)调用了许多这些图像)。我希望使用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) ?>" />

请注意,助手的初始功能采用以下输入:

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是商店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 . '"/>';
}

?>

将其送达查询:

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是Zoom Image模块的不良代码。

Disable it to get the work.

在需要时生成文件。您需要打电话 Mage::helper('catalog/image)->... 创建这些图像。您可以手动执行此操作,也可以写一个脚本将所有请求重定向到 /media/ 对此脚本确实会及时生成图像

许可以下: CC-BY-SA归因
scroll top