/** * * removes concrete model's image * @param Image $img * @throws \Exception */ public function removeImage(\rico\yii2images\models\Image $img) { if (!$img->isNewRecord) { $imgInfoweb = Image::findOne(['id' => $img->id]); $imgInfoweb->clearCache(); $storePath = $this->getModule()->getStorePath(); $fileToRemove = $storePath . DIRECTORY_SEPARATOR . $img->filePath; if (preg_match('@\\.@', $fileToRemove) and is_file($fileToRemove)) { unlink($fileToRemove); } $img->delete(); } }
/** * * removes concrete model's image * @param Image $img * @throws \Exception */ public function removeImage(Image $img) { $img->clearCache(); $storePath = $this->getModule()->getStorePath(); $fileToRemove = $storePath . DIRECTORY_SEPARATOR . $img->filePath; if (preg_match('@\\.@', $fileToRemove) and is_file($fileToRemove)) { unlink($fileToRemove); } $img->delete(); }