/**
  * Finds the Image model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Image the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Image::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException(Yii::t('app', 'The requested item does not exist'));
     }
 }
Beispiel #2
0
 /**
  * Removes an image with a specific identifier
  * 
  * @param   string  $identifier     The identifier of the image
  * @return  boolean
  */
 public function removeImageByIdentifier($identifier = '')
 {
     if ($identifier == '') {
         return $this->owner->removeImages();
     }
     $image = Image::findOne(['identifier' => $identifier, 'itemId' => $this->owner->id, 'modelName' => $this->getModule()->getShortClass($this->owner)]);
     if ($image) {
         $this->owner->removeImage($image);
     }
     return true;
 }
 /**
  * Get the popup image for images gridview
  *
  * @return string
  */
 public function getPopupImage($id = null)
 {
     $image = Image::findOne($id);
     return '<a class="fancybox" data-pjax="0" rel="fancybox" href="' . $image->getUrl("{$this->width}x{$this->height}") . '"><img src="' . $image->getUrl('80x80') . '" /></a>';
 }