yii-dream-team / yii2-upload-behavior

Yii2 file/image upload behavior for ActiveRecord
http://yiidreamteam.com/yii2/upload-behavior
MIT License
77 stars 45 forks source link

How to generate multiple thumbnails? #7

Closed jomonkj closed 8 years ago

jomonkj commented 9 years ago

Is it correct?I got error

        [
                'class' => '\yiidreamteam\upload\ImageUploadBehavior',
                'attribute' => 'image',
                'thumbs' => [
                    'thumb' => ['width' => 400, 'height' => 300],
                    'thumbNail' => ['width' => 178, 'height' => 181],
                ],
                'filePath' => '@storage/uploads/event/gallery/[[attribute_event_id]]/[[pk]]/[[pk]].[[filename]].[[extension]]',
                'fileUrl' =>'@storageUrl/uploads/event/gallery/[[attribute_event_id]]/[[pk]]/[[pk]].[[filename]].[[extension]]',
                'thumbPath' => '@storage/uploads/event/gallery/[[attribute_event_id]]/thumb/[[pk]]/[[pk]].[[filename]].[[extension]]',
                'thumbUrl' =>  '@storageUrl/uploads/event/gallery/[[attribute_event_id]]/thumb/[[pk]]/[[pk]].[[filename]].[[extension]]',
                'thumbNailPath' => '@storage/uploads/event/gallery/[[attribute_event_id]]/thumbNail/[[pk]]/[[pk]].[[filename]].[[extension]]',
                'thumbNailUrl' =>  '@storageUrl/uploads/event/gallery/[[attribute_event_id]]/thumbNail/[[pk]]/[[pk]].[[filename]].[[extension]]',
            ],
metalagman commented 8 years ago

check that part:

                'thumb' => ['width' => 400, 'height' => 300],
                'thumbNail' => ['width' => 178, 'height' => 181],

you are able to use [[profile]] placeholder to store thumbnails both for 'thumb' and 'thumbNail' thumb profiles.