简体   繁体   中英

Programmatically get the width and height of a product image in Magento?

Inside Magento templating code I want to get the width and height of the original product image (uploaded by admin when creating product), so as to make according adjustments.

How can I do this? Thus far I have:

$this->helper('catalog/image')->init($_product, 'image')

Does this have any methods that would allow me to retrieve the original dimensions of the product image? Such as:

$this->helper('catalog/image')->init($_product, 'image')->getWidth()

Or something?

Thanks!

Just found it in the docs: http://docs.magentocommerce.com/Mage_Catalog/Mage_Catalog_Helper_Image.html

Seems it's:

$this->helper('catalog/image')->init($_product, 'image')->getOriginalHeight()
$this->helper('catalog/image')->init($_product, 'image')->getOriginalWidth()

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