简体   繁体   中英

Magento - Product image spacing at top and bottom

For some reason when uploading a product image, magento is adding some spacing to the top and bottom of the image.

This is an example image. Because Stackoverflow has a white background, if you save this image you will see the white spacing along the top and bottom.

这是一个示例图像。如果保存此图像,您将在顶部和底部看到白色间距。

This is a link to the site if you'd like to have a look in the store environment.

Any help will be much appreciated.

Regards

This is caused by your theme's aspect ratio set on the thumbnail images. Since the image size is set to 232 x 280 , and the image you are uploading is square, Magneto automatically generates a version of the image at the size it's called.

To modify the size and set it to a square aspect ratio, you can simply modify your theme's template file.

Open app/design/frontend/default/celebrity/templates/catalog/product/list.phtml

Look for your image tag(s), it will look something like this:

<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(232,280); ?>" width="232" height="280" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />

Modify the height and width values to be the same, like this:

<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(232); ?>" width="232" height="232" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />

Save the file, and refresh your Magento caches.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM