doudi7782 2013-03-25 08:38
浏览 37
已采纳

Magento media.phtml产品<img>有style =“top:”?

I wanted to move the product.info.media block from the catalog.xml in the left column for all product view.

To achive this, i have added two lines to my local.xml file:

<catalog_product_view>
    <reference name="left">
        <block type="catalog/product_view_media" name="product.info.media" as="media" template="catalog/product/view/media.phtml"/>
    </reference>
    <reference name="product.info">
        <action method="unsetChild"><child>media</child></action>
    </reference>
</catalog_product_view>

The media.phtml is binary identical with the default file from the 1.7.0.2 version of magento.

The strange thing is, that the product image on the webpage has this code:

<img id="image" src="path/to/image.jpg" alt="" title="" style="position: relative; left: 0px; width: 220px; top: 215px;">

Why is there a style defined for top?! As this style is defined inside the element i can't even change it with css. Could anyone explain this behaviour of magento?

The lines in the media.phtml which are creating this look like this:

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

They lead me to app/code/core/Mage/Catalog/Helper/Output.php where the productAttribute function is defined. But why for heavens sake is the top style set? It makes no sense at all. If i wanted to set it i would use css.

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • dsbifvcxr458755493 2013-08-06 20:51
    关注

    I just spent the past 3 hours banging my head against this problem... The solution? The element style (including 'top') is set in (drumroll) /js/product.js. This is part of the default image zoom operation. Hope this helps anyone out there who comes across this post through Google like I did.

    In magento 1.7.2, line 263 of /js/product.js shows:

    this.imageEl.style.top = this.imageY+'px';
    

    As a quick hack you can comment it out, but I highly recommend adapting a zoom javascript functionality that suits your needs.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起