Beispiel #1
0
 /**
  * @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);
     }]]];
 }
Beispiel #2
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [\app\components\NoDeleteBehavior::className()];
 }