Skip to content
This repository has been archived by the owner on Dec 9, 2023. It is now read-only.

Added possibility to define Templates with arguments #62

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/Intervention/Image/ImageCacheController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function getResponse($template, $filename)

case 'download':
return $this->getDownload($filename);

default:
return $this->getImage($template, $filename);
}
Expand Down Expand Up @@ -55,7 +55,7 @@ public function getImage($template, $filename)
// build from filter template
$image->make($path)->filter($template);
}

}, config('imagecache.lifetime'));

return $this->buildResponse($content);
Expand Down Expand Up @@ -106,9 +106,14 @@ private function getTemplate($template)
return $template;

// filter template found
case class_exists($template):
case is_string($template) && class_exists($template):
return new $template;


// filter with arguments template found
case is_array($template):
$rc = new \ReflectionClass(array_shift($template));
return $rc->newInstanceArgs($template);

default:
// template not found
abort(404);
Expand Down Expand Up @@ -141,7 +146,7 @@ private function getImagePath($filename)
/**
* Builds HTTP response from given image data
*
* @param string $content
* @param string $content
* @return Illuminate\Http\Response
*/
private function buildResponse($content)
Expand Down