Reputation: 676
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?
Upvotes: 1
Views: 1085
Reputation: 56
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
Upvotes: 3
Reputation: 1726
I just needed this yesterday.
Just use this extension: Image Yii Extension
Follow the instructions to installation and usage in the page.
Upvotes: 0