Commit 8b5b2713 authored by Nicolas Widart's avatar Nicolas Widart

Refacoring and adding direct getter

parent 51ea1b55
...@@ -73,7 +73,8 @@ class MediaController extends AdminBaseController ...@@ -73,7 +73,8 @@ class MediaController extends AdminBaseController
*/ */
public function edit(File $file) public function edit(File $file)
{ {
dd($this->imagy->get('/assets/media/screen-shot-2014-10-25-at-44939-pm.png', 'smallThumb', true)); //dd($this->imagy->get('/assets/media/screen-shot-2014-10-25-at-44939-pm.png', 'smallThumb', true));
//dd($this->imagy->getThumbnail('/assets/media/screen-shot-2014-10-25-at-44939-pm.png', 'smallThumb'));
return View::make('media::admin.edit', compact('file')); return View::make('media::admin.edit', compact('file'));
} }
......
...@@ -45,17 +45,20 @@ class Imagy ...@@ -45,17 +45,20 @@ class Imagy
return $filename; return $filename;
} }
$image = $this->image->make(public_path() . $path); $this->makeNew($path, $thumbnail, $filename);
foreach ($this->config->get("media::thumbnails.{$thumbnail}") as $manipulation => $options) { return $filename;
$image = $this->imageFactory->make($manipulation)->handle($image, $options);
} }
$image = $image->encode(pathinfo($path, PATHINFO_EXTENSION)); /**
* Return the thumbnail path
$this->writeImage($filename, $image); * @param string $originalImage
* @param string $thumbnail
return $filename; * @return string
*/
public function getThumbnail($originalImage, $thumbnail)
{
return '/assets/media/' . $this->newFilename($originalImage, $thumbnail);
} }
/** /**
...@@ -91,4 +94,23 @@ class Imagy ...@@ -91,4 +94,23 @@ class Imagy
{ {
$this->finder->put(public_path() . $filename, $image); $this->finder->put(public_path() . $filename, $image);
} }
/**
* Make a new image
* @param string $path
* @param string $thumbnail
* @param string $filename
*/
private function makeNew($path, $thumbnail, $filename)
{
$image = $this->image->make(public_path() . $path);
foreach ($this->config->get("media::thumbnails.{$thumbnail}") as $manipulation => $options) {
$image = $this->imageFactory->make($manipulation)->handle($image, $options);
}
$image = $image->encode(pathinfo($path, PATHINFO_EXTENSION));
$this->writeImage($filename, $image);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment