예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function respond(Transaction $transaction)
 {
     $transaction->setErrorImage($this->errorImage);
     $image = $this->finder->find($transaction->getFilePath());
     $transaction->setSrcImage($image);
     // Get the thumbnail from cache or create it
     $thumbnail = $this->getThumbnail($transaction);
     // Save static copy if enabled
     $this->saveStaticThumbnail($transaction->getRequestPath(), $thumbnail);
     // Return thumbnail
     return new Thumbnail($image, $thumbnail);
 }
예제 #2
0
 /**
  * Verifies that the image's info can be read correctly.
  * If the src image fails, it tries the error image as the fallback.
  *
  * @param Transaction $transaction
  *
  * @throws RuntimeException If both src and error images fail to be read.
  */
 protected function verifyInfo(Transaction $transaction)
 {
     try {
         $transaction->getSrcImage()->getInfo();
         return;
     } catch (IOException $e) {
     }
     $transaction->setSrcImage($transaction->getErrorImage());
     try {
         $transaction->getSrcImage()->getInfo();
     } catch (IOException $e) {
         throw new RuntimeException('There was an error with the thumbnail image requested and additionally the fallback image could not be displayed.', 1, $e);
     }
 }