Neru
Neru

Reputation: 676

Image dimension in yii framework

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

Answers (2)

farw
farw

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

Alexandre Justino
Alexandre Justino

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

Related Questions