public function actionRemoveAll()
 {
     $items = Yii::$app->request->post('items', []);
     if (!empty($items)) {
         $items = ThumbnailSize::find()->where(['in', 'id', $items])->all();
         foreach ($items as $item) {
             $item->delete();
         }
     }
     return $this->redirect(['index']);
 }
Ejemplo n.º 2
0
 public function actionRecreateThumbnails($idList = null, $showProgress = false)
 {
     /** @var ThumbnailSize[] $sizes */
     $sizes = ThumbnailSize::find()->all();
     /** @var Image[] $images */
     if (is_null($idList)) {
         $images = Image::find()->all();
     } else {
         $ids = explode(',', $idList);
         $images = Image::findAll(['id' => $ids]);
     }
     foreach ($images as $image) {
         if ($showProgress) {
             echo "Image: {$image->id}\n";
         }
         if ($image !== null) {
             foreach ($sizes as $size) {
                 Thumbnail::createThumbnail($image, $size);
             }
         }
     }
 }