Magento – Full images in media.phtml

media

I've this code on template/default/catalog/product/view/media.phtml page. I want to retrieve full size gallery images to display here in li's under ul's. The problem is that with this code, i'm getting thumbnail size media images.

<?php
    $_product = $this->getProduct();
    $_helper = $this->helper('catalog/output');
    $imgSize = 286;
?>
<ul class="rr images">
<?php $j=1; ?>
<?php foreach ($_images as $_image): ?> 
    <li class="<?php if ($j==1) echo "current"; echo ""; ?> gal-<?php echo $j?>">
      <img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize($imgSize, NULL); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>"/>
    </li>
    <?php $j++; ?>
<?php endforeach; ?>
</ul>

This is what i'm getting now:

This is what i'm getting now

This is what i want to get:

This is what i want to get

Please note that the problem is not with the size of the image (thumbnail image is of good size), but the dimensions of it(thumbnail image is cropped).

Best Answer

<?php
  $_product = $this->getProduct();
  $_helper = $this->helper('catalog/output');
  $imgSize = 286;
?>
<ul class="rr images">
 <?php $j=1; ?>
  <?php foreach ($_images as $_image): ?> 
   <li class="<?php if ($j==1) echo "current"; echo ""; ?> gal-<?php echo $j?>">
    <img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'small_image', $_image->getFile())->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize($imgSize, NULL); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>"/>
</li>
<?php $j++; ?>

you can gve three options for the image, small_image,thumbnail based on you want.

Related Topic