cancel
Showing results for 
Search instead for 
Did you mean: 

Different image size on different categories

Different image size on different categories

Hello all.

 

We are running Magento 1.9.0.1

 

Is it possible to have different image size in the template on each category ?

The problem is that one category has original pictures in landscape while other categories has original pictures in portrait.  Our window size for product images are in portrait format so when we add pictures in landscape they dont look very nice.  We are not able to crop the pictures because then we loose valuable information. Resizing does not work out either so we wonder if its possible to set different image size for each category.

 

Thanks

 

Petter

 

 

5 REPLIES 5

Re: Different image size on different categories

You can add different size image as your category requirement

<?php 
echo $this->helper('catalog/image')->init($_product, 'small_image')
    ->constrainOnly(false)
    ->keepAspectRatio(true)
    ->keepFrame(true)
    ->resize(160, 210);
?>
Find helpful ? Consider Giving Kudos to this post.
Problem solved? Click Accept as Solution!"
Qaisar Satti

Re: Different image size on different categories

Thanks a lot.

 

Can you tell me were I put this code ?

 

 

Petter

Re: Different image size on different categories

you can put this code

app/design/frontend/Spacename/Themename/template/catalog/product/list.phtml
Change below code on line 50

<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
Find helpful ? Consider Giving Kudos to this post.
Problem solved? Click Accept as Solution!"
Qaisar Satti

Re: Different image size on different categories

You can create the images with same dimensions on the fly like this in yourapp/design/frontend/[theme]/[name]/catalog/product/list.phtml where is defined the image:

$imageSource = $this->helper('catalog/image')
    ->init($_product, 'image')
    ->constrainOnly(true)
    ->keepAspectRatio(true)
    ->keepFrame(true)
    ->keepTransparency(true)
    ->backgroundColor(array(255,255,255))
    ->quality(75) // as option
    ->resize([imagewidth], [imageheight]); // set width and height

Go to the image-tag and set for the src-attribute <?php echo $imageSource; ?>

Re: Different image size on different categories

Hey Guys, 

 

I have added keepFrame(false) to my code and white space is removed but I got one more issue, images are not getting placed according to its container/grid when keepFrame is added to code.

 

Please help.

 

Thanks,

Wasim