簡體   English   中英

Magento media.phtml產品 <img> 是否具有style =“ top:”?

[英]Magento media.phtml product <img> has style=“top: ”?

我想從所有產品視圖的左列中的catalog.xml中移動product.info.media塊。

為了達到這個目的,我在local.xml文件中添加了兩行:

<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>

media.phtml是二進制文件,與magento 1.7.0.2版本中的默認文件相同。

奇怪的是,網頁上的產品圖片具有以下代碼:

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

為什么為top定義了樣式? 由於此樣式是在元素內部定義的,因此我什至無法使用CSS更改它。 誰能解釋一下magento的這種行為?

media.phtml中正在創建的行如下所示:

    $_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');

他們將我帶到定義了productAttribute函數的app/code/core/Mage/Catalog/Helper/Output.php 但是,為什么為了天堂而設置了頂級樣式? 這根本沒有意義。 如果我想設置它,我會使用CSS。

提前致謝。

我剛剛花了3個小時來解決這個問題……解決方案? 元素樣式(包括“ top”)在( /js/product.js中設置 這是默認圖像縮放操作的一部分。 希望這對像我一樣通過Google看到此帖子的人有所幫助。

在magento 1.7.2中,/ js / product.js的第263 顯示:

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

作為快速技巧,您可以將其注釋掉,但是我強烈建議您調整適合您需求的縮放javascript功能。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM