Open Mirol1988 opened 3 years ago
public function actionImageByItemAndAlias($item=''/, $dirtyAlias/) { $dirtyAlias = Yii::$app->request->get('dirtyAlias');
$dotParts = explode('.', $dirtyAlias); if(!isset($dotParts[1])){ throw new \yii\web\HttpException(404, 'Image must have extension'); } $dirtyAlias = $dotParts[0]; $size = isset(explode('_', $dirtyAlias)[1]) ? explode('_', $dirtyAlias)[1] : false; $alias = isset(explode('_', $dirtyAlias)[0]) ? explode('_', $dirtyAlias)[0] : false; $image = $this->getModule()->getImage($item, $alias); if($image->getExtension() != $dotParts[1]){ throw new \yii\web\HttpException(404, 'Image not found (extenstion)'); } if($image){ header('Content-Type: image/jpg'); echo $image->getContent($size); }else{ throw new \yii\web\HttpException(404, 'There is no images'); } }
public function actionImageByItemAndAlias($item=''/, $dirtyAlias/) { $dirtyAlias = Yii::$app->request->get('dirtyAlias');