在OpenCart 2上使用产品的真实图像的正确工作方式 [英] Proper way to work using the real image of a product on OpenCart 2

查看:66
本文介绍了在OpenCart 2上使用产品的真实图像的正确工作方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在寻找一种使用产品的真实图像而不是其缩略图(在默认主题中标识为$thumb)的主题的正确方法.

I'm currently looking for the proper way to work on a theme using the real image of a product and not its thumbnail (identified as $thumb in the default theme).

通过在控制器文件中添加一行,我发现了一个突然的把戏:

I have found a abrupt trick by adding a line in the controller file:

$this->data['cover'] = $product_info['image'];

但是,有没有人遇到过更好的方法(例如,使用 vqmod )来检索这些真实图像数据而无需更改控制器内容(用于模板页面,例如product.tplcategory.tpl例如)?

But does anybody have experienced a better method (eg with vqmod) to retrieve these real image data without changing controller content (for using in template pages, such as product.tpl or category.tpl for example)?

推荐答案

vQmod ) . 因此,需要在vqmod/xml文件夹中创建一个.xml文件,该文件包含以下内容:

With help from members of OpenCart forum, I managed to find a functional solution (using vQmod). It is thus require to create an .xml file placed in the vqmod/xml folder and containing, for example:

<?xml version="1.0" encoding="utf-8"?>
<modification>
    <id>Recover Real Image</id>
    <version></version>
    <vqmver></vqmver>
    <author></author>
    <email></email>
    <website></website>
    <file name="catalog/controller/product/product.php">
    <operation>
        <search position="after"><![CDATA[
            $data['points'] = $product_info['points'];
        ]]></search>
        <add><![CDATA[
            $data['picture'] = HTTP_SERVER.'/image/'.$product_info['image'];
        ]]></add>
    </operation>
    </file>
</modification>

如果找不到产品图片,并假定将<default.jpg>放在<image>文件夹的根目录中,则<add>元素可以替换为:

If product image can not be found and assuming a <default.jpg> is put the root of the <image> folder, the <add> element can be replaced by:

if(empty($product_info['image'])){
    $data['picture'] = HTTP_SERVER.'image/default.jpg';
}
else{
    $data['picture'] = HTTP_SERVER.'image/'.$product_info['image'];
}

使用以下其他可能的建议:

Other possible suggestions, by using:

  • OCmod can be found here
  • Image Autosize extension can be found here

这篇关于在OpenCart 2上使用产品的真实图像的正确工作方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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