2015-06-24 33 views
0

我正在開發一個藝術畫廊的網站,所以他們的所有產品圖片都有不同的寬度和高度,具體取決於藝術作品。我希望圖像每次顯示寬度爲630px,但取決於圖像,在頁面上延伸的時間要比其他頁面長。目前,我知道我可以調整位於我可以讓Magento的產品視圖中的圖像具有設定的寬度,但流體高度?

/app/design/frontend/default/theme706/template/ecommerceteam/cloud-zoom /目錄下的media.php文件中的產品圖片的$ bigImageX和$ bigImageY/product/view

但這隻允許我設置特定寬度高度。如果我只設置高度,它會縮小,使寬度與高度相同。

<div class="product-img-box"> 
    <script type="text/javascript" src="http://citizen.bluelotuscreative.com/skin/frontend/default/theme706/js/klass.min.js"></script> 
    <script type="text/javascript" src="http://citizen.bluelotuscreative.com/skin/frontend/default/theme706/js/code.photoswipe.jquery-3.0.5.js"></script> 


    <div class="product-box-customs"> 
     <p class="product-image"> 
     <img src="http://citizen.bluelotuscreative.com/media/catalog/product/cache/1/image/630x630/9df78eab33525d08d6e5fb8d27136e95/placeholder/default/Citizen_Atelier_-_Ashley_Woodson_Bailey_2__2.jpg" alt="Test Product" title="Test Product" /> </p> 

    </div> 
</div> 

$bigImageX = 630; 
$bigImageY = ???; 

<div class="product-box-customs"> 
    <?php if ($product->getImage() != 'no_selection' && $product->getImage()): ?> 

    <p class="product-image"> 
     <a href='<?php echo $this->helper('catalog/image')->init($product, 'image')->resize($bigImageWidth, $bigImageHeight);?>' class = 'cloud-zoom' id='zoom1' rel="<?php echo implode($config, ',');?>"> 
      <img class="big" src="<?php echo $this->helper('catalog/image')->init($product, 'image')->resize($bigImageX, $bigImageY);?>" alt='' title="<?php echo $this->htmlEscape($this->getImageLabel());?>" /> 
     </a> 
    </p> 

    <?php else: ?> 
    <p class="product-image"> 
     <?php 
     $_img = '<img src="'.$this->helper('catalog/image')->init($product, 'image')->resize($bigImageX, $bigImageY).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />'; 
     echo $outputHelper->productAttribute($product, $_img, 'image'); 
     ?> 
    </p> 
+0

你能後的模板代碼,因爲這是一個自定義模板? –

+0

嘿,我添加了代碼。 –

回答

1

替換:

$this->helper('catalog/image')->init($product, 'image')->resize($bigImageWidth, $bigImageHeight); 

有了這個:

$this->helper('catalog/image')->init($_product, 'image') 
->constrainOnly(TRUE) 
->keepAspectRatio(TRUE) 
->keepFrame(FALSE) 
->resize($bigImageWidth,null); 
+0

謝謝sooooo多!現在我可以停止將我的頭撞在牆上。 :) –

相關問題