使用Laravel的干预图像缓存:工作一次,然后“图像无法显示,因为它包含错误”


Intervention Image cache with Laravel: works once, then "Image cannot be displayed as it contains errors"

根据问题标题,我正在使用Laravel的干预包。我的路由文件中有以下代码:

Route::get('resize-image/{pathkey}/{filename}/{w?}/{h?}', function($pathkey, $filename, $w=100, $h=100){
    $cacheimage = Image::cache(function($image) use($pathkey, $filename, $w, $h){
        switch($pathkey){
            case 'tour-images':
                $filepath = 'upload/tour-images/' . $filename;
                break;
        }
        return $image->make($filepath)->resize($w,$h);
    },10,true); // cache for 10 minutes
    return Response::make($cacheimage, 200, array('Content-Type' => 'image/jpeg'));
});

当我使用类似以下内容调用图像时: /resize-image/tour-images/139326085726.jpg/1100/400它工作得很好,那么一旦我重新加载页面,我就会收到错误:

图像 xxxx 无法显示,因为它包含错误

如果我更改尺寸(因此迫使它再次调整图像大小(,它可以工作,然后..同样的问题。当我重新加载页面时,这次加载的应该是缓存的图像......但它不起作用。发生了什么事情?

好的,现在它开始工作了。如果我删除"true",那么它可以工作,即。更改此行代码:

},10,true); // cache for 10 minutes

自:

},10); // cache for 10 minutes

不知道为什么...我找不到任何告诉我"真实"指的是什么的信息(我从视频中复制了这段代码,几乎没有解释(。如果有人知道这意味着什么,请发表评论。