/**
  *
  * Returns replacement for text
  * (replaces [photo:id:width:height:mode] with resulting photo's image path)
  *
  * @param $entry
  * @param $placeholder
  * @return string
  */
 protected function getReplacement($entry, $placeholder)
 {
     list($id, $width, $height, $mode) = $this->getPhotoParams($placeholder);
     $photo = Photo::where('id', $id)->with('image')->first();
     if (!$photo) {
         return $placeholder;
     } else {
         if ($width && $height) {
             $path = $photo->image->getThumb($width, $height, ['mode' => $mode]);
         } else {
             $path = $photo->image->path;
         }
         return str_replace($placeholder, $path, $entry);
     }
 }
Exemple #2
0
 /**
  *
  * Loads photo to be displayed in this component
  *
  * @return PhotoModel
  */
 protected function loadPhoto()
 {
     $id = $this->property('id');
     $photo = PhotoModel::where('id', $id)->with('image')->with('album')->first();
     if ($photo) {
         // set url so we can have back link to the parent album
         $photo->album->url = $photo->album->setUrl($this->property('albumPage'), $this->controller);
         //set next and previous photos
         $photo->next = $photo->nextPhoto();
         if ($photo->next) {
             $photo->next->url = $photo->next->setUrl($this->property('photoPage'), $this->controller);
         }
         $photo->previous = $photo->previousPhoto();
         if ($photo->previous) {
             $photo->previous->url = $photo->previous->setUrl($this->property('photoPage'), $this->controller);
         }
     }
     return $photo;
 }