public function getImageByIdentifier($identifier = '', $fallbackToPlaceholder = true, $placeHolderPath = null)
{
if ($identifier == '') {
return $this->owner->getImage($fallbackToPlaceholder, $placeHolderPath);
}
if ($this->getModule()->className === null) {
$imageQuery = Image::find();
} else {
$class = $this->getModule()->className;
$imageQuery = $class::find();
}
$finder = $this->getImagesFinder(['identifier' => $identifier]);
$imageQuery->where($finder);
$img = $imageQuery->one();
if (!$img && $fallbackToPlaceholder) {
if (!$placeHolderPath) {
return new PlaceHolder();
} else {
return new Image(['filePath' => basename(Yii::getAlias($placeHolderPath)), 'urlAlias' => basename($placeHolderPath)]);
}
}
return $img;
}