Magento – New products on home page has blurry images after upgrading to Magento ver. 1.9.2.0

ce-1.9.2.0image

I upload my pictures at 864px by 864px. They look great on the product page (I also like that they no longer open a new window when clicked).

However, the first thing my customers see are the blurry new products images on the home page.

Using Chrome Inspect Element on the image, it appears to be resizing the image to 135, because I see these attributes: width="135" height="135"

However, chrome shows the image itself is 275×275 (actually, it says it is 274.844×275). So it seems the image is being resized to 135×135, then scaled up to 275×275 when displayed, thus making the image unnecessarily pixelated (blurry).

I've looked for the resize command that may be causing this, and found a potential culprit around line 50 in: app/design/frontend/default/my_theme/template/catalog/product/list.phtml

<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><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) ?>" /></a>

However, changing the width and height attributes to 275 and changing the resize(135) to resize(275) has no visible effect on the image.

Does anybody here know how to fix this problem?

Best Answer

I figured it out. I turned on template path hints to see exactly which file was being used to render the new products widget on the home page. It showed this path:

/app/design/frontend/base/default/template/catalog/product/new.phtml

The code to get the image was hard-coded to resize to 135!:

<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_product->getName()) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135) ?>" width="135" height="135" alt="<?php echo $this->escapeHtml($_product->getName()) ?>" /></a>

I know I should not edit this file directly, so I copied it into the following path (for the rwd theme, which is what I am using):

app/design/frontend/rwd/default/template/catalog/product/new.phtml

And then replaced that code with this code:

<?php $_imgSize=300; ?>
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_product->getName()) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_imgSize) ?>" width="<?php echo $_imgSize ?>" height="<?php echo $_imgSize ?>" alt="<?php echo $this->escapeHtml($_product->getName()) ?>" /></a>

Hopefully, this will help other people, too. It had me stumped for quite a while.

Related Topic