Commit 64c381c7 authored by Nicolas Widart's avatar Nicolas Widart

Adding a create all thumbs method

parent ff0eb00c
...@@ -117,18 +117,15 @@ class Imagy ...@@ -117,18 +117,15 @@ class Imagy
* @param string $filename * @param string $filename
* @param string null $thumbnail * @param string null $thumbnail
*/ */
private function makeNew($path, $filename, $thumbnail = null) private function makeNew($path, $filename, $thumbnail)
{ {
$image = $this->image->make(public_path() . $path); $image = $this->image->make(public_path() . $path);
$thumbnails = $thumbnail ?: $this->manager->all(); foreach ($this->manager->find($thumbnail) as $manipulation => $options) {
foreach ($thumbnails as $manipulation => $options) {
$image = $this->imageFactory->make($manipulation)->handle($image, $options); $image = $this->imageFactory->make($manipulation)->handle($image, $options);
} }
$image = $image->encode(pathinfo($path, PATHINFO_EXTENSION)); $image = $image->encode(pathinfo($path, PATHINFO_EXTENSION));
$this->writeImage($filename, $image); $this->writeImage($filename, $image);
} }
......
...@@ -39,4 +39,17 @@ class ThumbnailsManager ...@@ -39,4 +39,17 @@ class ThumbnailsManager
return $thumbnails; return $thumbnails;
} }
/**
* Find the filters for the given thumbnail
* @param $thumbnail
*/
public function find($thumbnail)
{
foreach ($this->all() as $thumbName => $filters) {
if ($thumbName == $thumbnail) {
return $filters;
}
}
}
} }
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