Beispiel #1
0
 public function getImage($item, $dirtyAlias)
 {
     $params = $data = $this->parseImageAlias($dirtyAlias);
     $alias = $params['alias'];
     $size = $params['size'];
     $itemId = preg_replace('/[^0-9]+/', '', $item);
     $modelName = preg_replace('/[0-9]+/', '', $item);
     $image = Image::find()->where(['modelName' => $modelName, 'itemId' => $itemId, 'urlAlias' => $alias])->one();
     if (!$image) {
         return $this->getPlaceHolder();
     }
     return $image;
 }
Beispiel #2
0
 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();
 }