yii框架中的图像维度 [英] Image dimension in yii framework
本文介绍了yii框架中的图像维度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
CHtml :: activeFileField()有没有办法获得图片尺寸(宽度,高度) CModel $ model,string $ attribute,array $ htmlOptions = array())
/ p>
CUploadedFile getInstance(CModel $ model,string $ attribute)
不幸的是,我找不到任何有用的信息 here
有什么想法?还是应该使用原始的php方法?
解决方案
您可以使用原生php函数getimagesize()。
在你的情况下:
$ p $ $ imageInfo = getimagesize(CUploadedFile :: getInstance($ model,'attributeName') - > getTempName());
$ image info变量返回数组,其中0和1元素分别是当前图像的宽度和高度
Is there any way to get image dimension (width, height) with upload image by:
CHtml::activeFileField(CModel $model, string $attribute, array $htmlOptions=array ( ))
and later with:
CUploadedFile getInstance(CModel $model, string $attribute)
Unfortunately I couldn't find any useful information here
any ideas? Or should I use raw php methods?
解决方案
You can use native php function getimagesize(). In your case:
$imageInfo = getimagesize(CUploadedFile::getInstance($model,'attributeName')->getTempName());
$image info variable returns array where 0 and 1 elements is width and height of the current image respectively
这篇关于yii框架中的图像维度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文