Generate cache
This commit is contained in:
parent
341349848d
commit
73e6e15e24
|
@ -100,7 +100,7 @@ class Plugin extends PluginBase
|
|||
return [
|
||||
'filters' => [
|
||||
'resize' => function($media, $size = 'original') {
|
||||
return app(TagGenerator::class)->generate($media, $size);
|
||||
return Cache::rememberForever("resize.{$size}.{$media}", fn () => app(TagGenerator::class)->generate($media, $size));
|
||||
},
|
||||
]
|
||||
];
|
||||
|
|
|
@ -5,8 +5,10 @@ namespace Aweos\Resizer\Tests\MediaTest;
|
|||
use Aweos\Resizer\Classes\TagGenerator;
|
||||
use Aweos\Resizer\Models\Setting;
|
||||
use Aweos\Resizer\Tests\TestCase;
|
||||
use Cache;
|
||||
use Event;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use October\Rain\Parse\Twig;
|
||||
use Storage;
|
||||
|
||||
class ImageTagTest extends TestCase
|
||||
|
@ -85,6 +87,18 @@ class ImageTagTest extends TestCase
|
|||
));
|
||||
}
|
||||
|
||||
public function testGenerateCache()
|
||||
{
|
||||
Setting::set('folders', ['pages']);
|
||||
Setting::set('sizes', [['name' => 'size', 'aspect_ratio' => '1200x280']]);
|
||||
Setting::set('breakpoints', [640]);
|
||||
$this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 1920, 899)->get());
|
||||
UploadedFile::fake()->image('test.jpg', 640, 149)->storeAs('uploads/public/c/pages', 'test-640x149.jpg', 'local');
|
||||
|
||||
$output = app(Twig::class)->parse('{{"pages/test.jpg" | resize}}');
|
||||
$this->assertEquals($output, Cache::get('resize.original.pages/test.jpg'));
|
||||
}
|
||||
|
||||
public function testPickOriginalImageWhenSvgIsGiven()
|
||||
{
|
||||
Setting::set('folders', ['pages']);
|
||||
|
|
Loading…
Reference in New Issue