[英]Magento media.phtml product <img> has style=“top: ”?
[英]Issue with resizing the image in product view page (media.phtml) magento
我正在嘗試在產品視圖頁面中調整圖像的大小,但是在調整圖像大小之后,左右兩側(寬度)都出現了空格,在調整大小功能中,我給了值338,474,但是它帶有空格。 為此,我應用了函數keepFrame(false)
。
但是在應用之后,我的圖像高度保持不變,但是寬度變為271。我該怎么辦? 下面是我的代碼。
<img src="<?php echo $this->helper('catalog/image')->init($product, 'image')->keepFrame(false)->resize(338,474);?>" alt='' title="<?php echo $this->htmlEscape($this->getImageLabel());?>" />
我在resize(338,474)
之前和之后都嘗試過keepFrame(false)
resize(338,474)
。 拜托,如果有人可以幫助我。
只需在以下函數resize
傳遞您的高度和寬度
$_img = '<img src="'.$this->helper('catalog/image')->init($_product, 'image')->resize(338, 474).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />';
嘗試執行以下步驟(假設您想要150寬度):
在同一行(54)上查找。
$ _image-> getFile()-> resize(150,150);
都好。 只需將這些數字之一替換為0,圖像就會自動縮放。 例如:
$_image->getFile()->resize(150, 0);
它將為您提供150像素寬的圖像,但是高度會根據原始圖像比率而變化。
希望能有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.