【发布时间】:2019-03-23 04:11:30
【问题描述】:
当我上传图片时(例如:user/1/user_profile_img.jpg),我希望干预图片创建多个缩略图尺寸(100x100、200x200、400x400 等),这些尺寸将用于不同的页面以改进页面速度得分。
我应该将不同的缩略图大小(100x100、200x200、400x400 等)存储在自定义的/cache/ 文件夹中吗?比如'/cache/user/1/user_profile_img-100x100.jpg'?
或者我在使用干预图像缓存调整大小路由访问页面时生成它们,例如:
{{ route('photos/item/100x100/userprofile/user_profile_img.jpg') }}
在blade.php 模板中?
Route::get('photos/item/{size}/{reference}/{photo}', 'ImgController@showImg');
我看到干预图像缓存函数中有一个'lifetime (optional)'参数:
$img = Image::cache(function($image) {
$image->make('public/foo.jpg')->resize(300, 200)->greyscale();
}, 10, true);
图片回调在缓存中的生命周期(分钟)。
是用来设置图片缓存过期时间的吗?
图片会自动从/cache/文件夹中删除吗?
【问题讨论】:
标签: php laravel intervention image-caching