Esempio n. 1
0
 /**
  *
  * 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();
     }
 }
Esempio n. 2
0
 /**
  *
  * 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();
 }