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); } } } }