/** * Returns a list of behaviors that this component should behave as. * * @return array */ public function behaviors() { return [TimestampBehavior::className(), 'galleryBehavior' => ['class' => GalleryBehavior::className(), 'type' => 'about', 'extension' => 'jpg', 'directory' => Yii::getAlias('@webroot') . '/uploads/about', 'url' => Yii::getAlias('@web') . '/uploads/about', 'versions' => ['medium' => function ($img) { /** @var Imagine\Image\ImageInterface $img */ $dstSize = $img->getSize(); $maxWidth = 800; if ($dstSize->getWidth() > $maxWidth) { $dstSize = $dstSize->widen($maxWidth); } return $img->copy()->resize($dstSize); }]]]; }
/** * @inheritdoc */ public function behaviors() { return [\app\components\NoDeleteBehavior::className(), self::GALLERY_IMAGE_BEHAVIOR => ['class' => \zxbodya\yii2\galleryManager\GalleryBehavior::className(), 'tableName' => '{{%product_image}}', 'type' => self::GALLERY_IMAGE_TYPE, 'extension' => 'jpg', 'directory' => Yii::getAlias('@webroot/images/product/'), 'url' => Yii::getAlias('@web/images/product/'), 'timeHash' => false, 'versions' => ['small' => function ($img) { /** @var \Imagine\Image\ImageInterface $img */ return $img->copy()->thumbnail(new \Imagine\Image\Box(200, 200)); }, 'medium' => function ($img) { /** @var Imagine\Image\ImageInterface $img */ $dstSize = $img->getSize(); $maxWidth = 800; if ($dstSize->getWidth() > $maxWidth) { $dstSize = $dstSize->widen($maxWidth); } return $img->copy()->resize($dstSize); }]]]; }
public function behaviors() { return ['galleryBehavior' => ['class' => GalleryBehavior::className(), 'type' => 'gallery', 'extension' => 'jpg', 'directory' => Yii::getAlias('@webroot') . '/images/product/gallery', 'url' => Yii::getAlias('@web') . '/images/product/gallery', 'versions' => ['small' => function ($img) { /** @var \Imagine\Image\ImageInterface $img */ return $img->copy()->thumbnail(new \Imagine\Image\Box(200, 200)); }, 'medium' => function ($img) { /** @var \Imagine\Image\ImageInterface $img */ $dstSize = $img->getSize(); $maxWidth = 800; if ($dstSize->getWidth() > $maxWidth) { $dstSize = $dstSize->widen($maxWidth); } return $img->copy()->resize($dstSize); }]]]; }
/** * @inheritdoc */ public function behaviors() { return ['dt' => ['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'created_date', 'updatedAtAttribute' => 'updated_date', 'value' => new Expression('NOW()')], 'us' => ['class' => BlameableBehavior::className(), 'createdByAttribute' => 'created_user', 'updatedByAttribute' => 'updated_user'], 'galleryBehavior' => ['class' => GalleryBehavior::className(), 'type' => 'posts', 'extension' => 'jpg', 'directory' => Yii::getAlias('@webroot') . '/images/posts/gallery', 'url' => Yii::getAlias('@web') . '/images/posts/gallery', 'versions' => ['small' => function ($img) { /** @var \Imagine\Image\ImageInterface $img */ return $img->copy()->thumbnail(new \Imagine\Image\Box(200, 200)); }, 'medium' => function ($img) { /** @var Imagine\Image\ImageInterface $img */ $dstSize = $img->getSize(); $maxWidth = 800; if ($dstSize->getWidth() > $maxWidth) { $dstSize = $dstSize->widen($maxWidth); } return $img->copy()->resize($dstSize); }]]]; }
public function behaviors() { // ini_set('memory_limit', '64M'); return [['class' => Taggable::className()], Taggable::className(), TimestampBehavior::className(), 'galleryBehavior' => ['class' => GalleryBehavior::className(), 'type' => 'objreservation', 'extension' => 'jpg', 'directory' => Yii::getAlias('@root') . '/images/product/gallery', 'url' => '/images/product/gallery', 'versions' => ['small' => function ($img) { /** @var ImageInterface $img */ return $img->copy()->thumbnail(new Box(100, 100)); }, 'medium' => function ($img) { /** @var ImageInterface $img */ $dstSize = $img->getSize(); $maxWidth = 480; if ($dstSize->getWidth() > $maxWidth) { $dstSize = $dstSize->widen($maxWidth); } return $img->copy()->resize($dstSize); }]]]; }
/** * @inheritdoc */ public function behaviors() { return [TimestampBehavior::className(), SaveUserRole::className(), 'uploadFile' => ['class' => UploadBehaviour::className(), 'fields' => ['image'], 'allowedFileExtentions' => ['png', 'jpg']], 'multipleUploadFile' => ['class' => UploadBehaviour::className(), 'fields' => ['file_collection_id'], 'allowedFileExtentions' => ['png', 'jpg'], 'multiple' => true], 'galleryBehavior' => ['class' => GalleryBehavior::className(), 'type' => 'user', 'extension' => 'jpg', 'directory' => Yii::getAlias('@webroot') . '/files/User/gallery', 'url' => Yii::getAlias('@web') . '/files/User/gallery']]; }
public function behaviors() { return ['galleryBehavior' => ['class' => GalleryBehavior::className(), 'type' => 'product', 'extension' => 'jpg', 'directory' => Yii::getAlias('@webroot') . '/img/exclusives', 'url' => Yii::getAlias('@web') . '/img/exclusives', 'hasName' => false, 'hasDescription' => false, 'versions' => []]]; }