public function actionDelete($id = null)
 {
     $model = ThumbnailSize::findOne($id);
     if ($model === null) {
         throw new NotFoundHttpException();
     }
     $model->delete();
     Yii::$app->session->setFlash('info', Yii::t('app', 'Object removed'));
     return $this->redirect(Yii::$app->request->get('returnUrl', Url::toRoute(['index'])));
 }
Exemplo n.º 2
0
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     $defaultSize = Yii::$app->getModule('image')->defaultThumbnailSize;
     $aSize = explode('x', $defaultSize);
     $size = ThumbnailSize::findOne(['width' => $aSize[0], 'height' => $aSize[1]]);
     if ($size !== null) {
         Thumbnail::getImageThumbnailBySize($this, $size);
     }
 }
Exemplo n.º 3
0
 /**
  * @inheritdoc
  * @param bool $insert
  * @param array $changedAttributes
  * @throws BadRequestHttpException
  */
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     if (Yii::$app->getModule('image')->useWatermark == 1) {
         /** @var ThumbnailSize $size */
         $size = ThumbnailSize::findOne(ArrayHelper::getValue($this, 'size_id', 0));
         if ($size !== null) {
             $watermark = Watermark::findOne($size->default_watermark_id);
             if ($watermark !== null) {
                 ThumbnailWatermark::getThumbnailWatermark($this, $watermark);
             }
         } else {
             throw new BadRequestHttpException(Yii::t('app', 'Set thumbnail size'));
         }
     }
 }