问题
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!
回答1:
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()
来源:https://stackoverflow.com/questions/9286441/programmatically-get-the-width-and-height-of-a-product-image-in-magento