mirror of
https://github.com/Intervention/image.git
synced 2025-08-22 13:32:56 +02:00
added cache method
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
namespace Intervention\Image;
|
namespace Intervention\Image;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Closure;
|
||||||
use Illuminate\Filesystem\Filesystem;
|
use Illuminate\Filesystem\Filesystem;
|
||||||
|
|
||||||
class Image
|
class Image
|
||||||
@@ -141,6 +142,26 @@ class Image
|
|||||||
return $image;
|
return $image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create new cached image and run callback
|
||||||
|
* (requires additional package intervention/imagecache)
|
||||||
|
*
|
||||||
|
* @param Closure $callback
|
||||||
|
* @return Image
|
||||||
|
*/
|
||||||
|
public static function cache(Closure $callback = null)
|
||||||
|
{
|
||||||
|
if ( ! class_exists('\Intervention\Image\ImageCache')) {
|
||||||
|
throw new Exception('Please install package intervention/imagecache before running this function.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create image and run callback
|
||||||
|
$image = new \Intervention\Image\ImageCache;
|
||||||
|
$image = is_callable($callback) ? $callback($image) : $image;
|
||||||
|
|
||||||
|
return $image->get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set properties for image resource from image file
|
* Set properties for image resource from image file
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user