Skip to content

Commit

Permalink
PlaceHolder added
Browse files Browse the repository at this point in the history
  • Loading branch information
CostaRico committed Aug 9, 2014
1 parent 61ac881 commit 12e082a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
11 changes: 10 additions & 1 deletion Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function getImage($item, $dirtyAlias)
])*/
->one();
if(!$image){
$image = new PlaceHolder();
return $this->getPlaceHolder();
}

return $image;
Expand Down Expand Up @@ -168,4 +168,13 @@ public function init()
throw new \Exception('Setup imagesStorePath and imagesCachePath images module properties!!!');
// custom initialization code goes here
}

public function getPlaceHolder(){

if($this->placeHolderPath){
return new PlaceHolder();
}else{
return null;
}
}
}
6 changes: 4 additions & 2 deletions behaviors/ImageBehave.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function getImages()

$imageRecords = $imageQuery->all();
if(!$imageRecords){
return [new models\PlaceHolder()];
return $this->getModule()->getPlaceHolder();
}
return $imageRecords;
}
Expand All @@ -191,7 +191,7 @@ public function getImage()

$img = $imageQuery->one();
if(!$img){
return new models\PlaceHolder();
return $this->getModule()->getPlaceHolder();
}

return $img;
Expand Down Expand Up @@ -282,6 +282,8 @@ private function getAlias()
}




}


4 changes: 2 additions & 2 deletions models/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ public function createVersion($imagePath, $sizeString = false)
}else{
$sizePart = '';
}
$pathToSave = $cachePath.'/'.$subDirPath.'/'.$this->urlAlias.$sizePart.'.'.$fileExtension;

$pathToSave = $cachePath.'/'.$subDirPath.'/'.$this->urlAlias.$sizePart.'.'.$fileExtension;

BaseFileHelper::createDirectory(dirname($pathToSave), 0777, true);

Expand Down Expand Up @@ -196,7 +196,7 @@ public function setMain($isMain = true){

}

private function getSubDur(){
protected function getSubDur(){
return $this->modelName. 's/' . $this->modelName.$this->itemId;
}

Expand Down
6 changes: 6 additions & 0 deletions models/PlaceHolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ public function getPathToOrigin()
return $url;
}

protected function getSubDur(){
return 'placeHolder';
}
public function setMain($isMain = true){
throw new yii\base\Exception('You must not set placeHolder as main image!!!');
}

}

0 comments on commit 12e082a

Please sign in to comment.