以编程方式获取Magento中产品图像的宽度和高度? [英] Programmatically get the width and height of a product image in Magento?

查看:123
本文介绍了以编程方式获取Magento中产品图像的宽度和高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

内部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()

还是什么?

谢谢!

推荐答案

刚刚在文档中找到它: http://docs.magentocommerce.com/Mage_Catalog/Mage_Catalog_Helper_Image.html

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

似乎是:

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

这篇关于以编程方式获取Magento中产品图像的宽度和高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆