dongmoyu0336
2017-01-23 15:04
浏览 259
已采纳

Opencart删除图像/缓存什么都不做

I'm having some serious trouble with Opencart cache image. I have a software which synchronizes the information (products, categories) etc with Opencart.

Whenever I update a product which has already an image, I just replace (in the FTP) the image - since it has the same description (the id).

--- First upload product ---
image/myfolder/id_of_image.jpg

--- Second upload product (update) ---
image/myfolder/id_of_image.jpg -> It is replaced

--- Third upload product (update) ---
image/myfolder/id_of_image.jpg -> It is replaced

And so on. What happens is that Opencart continues with the same image set in the first sync. This is not a browser issue since different browsers shows the same first image sync.

Opencart forces the image to resize whenever opening the product page, and creates a new internal file like 19301-500x445.jpg, depending on the image size. This only happens if the sized image doesn't exists already!

// Within the file catalog/model/tool/image

$image_old = $filename;
$image_new = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . (int)$width . 'x' . (int)$height . '.' . $extension;

if (!is_file(DIR_IMAGE . $image_new) || (filectime(DIR_IMAGE . $image_old) > filectime(DIR_IMAGE . $image_new))) 
{ 
}

I can manage to avoid cache issue by setting the time() in the filename, but by this way opencart will constantly create new images unnecessarily.

$image_new = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . (int)$width . 'x' . (int)$height . '-' . time() . '.' . $extension;

Deleting image/cache/myfolder/* does no effect whatsoever.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题