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
*/
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'));
}
......
......@@ -45,19 +45,22 @@ class Imagy
return $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);
$this->makeNew($path, $thumbnail, $filename);
return $filename;
}
/**
* Return the thumbnail path
* @param string $originalImage
* @param string $thumbnail
* @return string
*/
public function getThumbnail($originalImage, $thumbnail)
{
return '/assets/media/' . $this->newFilename($originalImage, $thumbnail);
}
/**
* Prepend the thumbnail name to filename
* @param $path
......@@ -91,4 +94,23 @@ class Imagy
{
$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